Cr41s3
Cr41s3

Reputation: 97

Nginx rewrite - .htacces to nginx

I want my apache .htaccess to work with nginx.

I've got this .htaccess file/code

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

I hope you can help me :)

Upvotes: 0

Views: 105

Answers (2)

tibbi
tibbi

Reputation: 249

if you want to keep the "index.php" in the url, I would do

    location / {
        try_files $uri $uri/ /index.php;
    }

    location ~ \.php$ {
        try_files $uri @redirect;
        ...
    }

    location @redirect {
        return 301 $1/index.php;
    }

Upvotes: 0

Xavier Lucas
Xavier Lucas

Reputation: 2642

It will transform to something of this kind with nginx :

server {

    server www.domain.com;

    index index.php;

    location / {
        try_files $uri $uri/ /index.php;
    }

    location ~\.php$ {
        ...
    }

}

Upvotes: 1

Related Questions