Eu converto part-by-part para seguir mais facilmente.
Apache:
RewriteCond %{HTTP_HOST} ^www.domain.com
RewriteRule (.*) http://domain.com/$1 [R=301,L]
Nginx:
server {
listen 80;
server_name www.domain.com;
root /var/www/localhost/htdocs;
rewrite ^ http://domain.com$request_uri permanent;
}
Apache:
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /(index|index\.php)\ HTTP/
RewriteRule ^(index|index\.php)$ http://domain.com/ [R=301,L]
Nginx:
location = /index {
try_files $uri @homepage;
}
location @homepage {
rewrite ^ http://domain.com break;
}
location ~ \.php$ {
if ($request_uri ~* /index\.php$) {
rewrite ^ http://domain.com break;
}
fastcgi_pass 127.0.0.1:9000;
include fastcgi.conf;
fastcgi_intercept_errors on;
error_page 404 /error/404.php;
}
Apache:
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^(.*)$ $1.php [L]
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^(.*)/$ http://domain.com/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /[^.]+\.php\ HTTP/
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^([^.]+)\.php$ http://domain.com/$1 [R=301,L]
Nginx:
rewrite ^/(.*)/$ /$1 permanent;
if (-f $document_root/$request_uri.php) {
rewrite ^(.*)$ $1.php last;
}
location ~ \.php$ {
if (-f $document_root/$request_uri) {
rewrite ^([^.]+)\.php$ http://domain.com$1 permanent;
}
...
}