Welcome! Log In Create A New Profile


Apache to nginx .htaccess

Posted by Levanov 
Apache to nginx .htaccess
August 13, 2012 09:45AM

I'm using Apache and have .htaccess like tihs.

RewriteEngine on
RewriteCond %{REQUEST_URI} !^/casastatus
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ dispatcher.php/$1

And I get requests like /dispatcher.php/cmd/somejob/1/XXXXXXXXXX

I just want to send these requests to php-fpm becaue php application has url dispatcher and Apache can understand dispather.php exists. When I configure nginx+php-fpm with this configuration; I get not found error in error log;

location ~* ^/dispatcher.php(.+)$ {
include /etc/nginx/fastcgi.conf;

How can i do this with nginx?

Thanx a lot
Re: Apache to nginx .htaccess
October 04, 2012 01:59PM
I actually found a .htaccess to nginx converter. I'm not sure how well it works (it comes with a disclaimer to check the output before using), but after pasting in your .htaccess example, it spit out the following code:

# nginx configuration

location ~ /casastatus {
location / {
if (!-e $request_filename) {
rewrite ^(.*)$ /dispatcher.php/$1;

I'm not too familiar with .htaccess or location directives in nginx, but it wouldn't (shouldn't) hurt to try.

Not sure if it will let me paste links, but here's a try for the converter:

Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 330
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready