Welcome! Log In Create A New Profile

Advanced

Convert Apache rewrite to NGinx

GASPARD kévin
March 03, 2013 07:54AM
Hi,

Using nginx 1.2.1 on Debian Wheezy 64 bits.

My wordpress need rewrite, it gave me this:


<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've tried to convert it with this website: http://winginx.com/htaccess.
The result is:


# nginx configuration

location / {
if (!-e $request_filename){
rewrite ^(.*)$ /index.php break;
}
}


I've put it into /etc/nginx/conf.d/doinalefort.fr.conf like this:


server {
listen 80;
listen 443 ssl;
# server_name 176.31.122.26;
server_name doinalefort.fr www.doinalefort.fr;
root /var/www/doinalefort.fr;

msie_padding on;

ssl_session_timeout 5m;

ssl_protocols SSLv2 SSLv3 TLSv1;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;

error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;

index index.php;
fastcgi_index index.php;

client_max_body_size 8M;
client_body_buffer_size 256K;

location ~ \.php$ {
include fastcgi_params;

# Assuming php-fastcgi running on localhost port 9000
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_param SCRIPT_FILENAME
$document_root$fastcgi_script_name;

fastcgi_connect_timeout 60;
fastcgi_send_timeout 180;
fastcgi_read_timeout 180;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
fastcgi_intercept_errors on;

location / {
if (!-e $request_filename){
rewrite ^(.*)$ /index.php break;
}
}

}
}

And restarted nginx, but it give me this error:


Restarting nginx: nginx: [emerg] location "/" is outside location "\.php$"
in /etc/nginx/conf.d/doinalefort.fr.conf:44
nginx: configuration file /etc/nginx/nginx.conf test failed


And idea?

Cordially, Koshie


--
Sorry for my english, I'm trying the best in each e-mail writing. Tell me
if I'm not clear enough.
This mail account is only for list reading, to contact me send an e-mail
at kevingaspard@koshie.fr

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Convert Apache rewrite to NGinx

GASPARD kévin March 03, 2013 07:54AM

Re: Convert Apache rewrite to NGinx

Francis Daly March 03, 2013 10:02AM

Re: Convert Apache rewrite to NGinx

GASPARD kévin March 03, 2013 01:40PM

Re: Convert Apache rewrite to NGinx

GreenGecko March 03, 2013 02:00PM

Re: Convert Apache rewrite to NGinx

GASPARD kévin March 03, 2013 02:20PM

Re: Convert Apache rewrite to NGinx

Francis Daly March 03, 2013 02:12PM

Re: Convert Apache rewrite to NGinx

GASPARD Kévin March 06, 2013 08:42AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 147
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