Welcome! Log In Create A New Profile

Advanced

Need help converting htaccess to nginx commands

Posted by RhoVisions 
Need help converting htaccess to nginx commands
February 19, 2011 01:32AM
Hi all,

Recently, I was asked to write a piece of code for a group of friends, and after completion, was told the server ran on NGINX. I've been reading the documentation to convert the htaccess I made to an equivalent for NGINX, but to no avail. I'm hoping someone can help.

Here is the htaccess I have.

[quote]ErrorDocument 401 errors/401
ErrorDocument 403 errors/403
ErrorDocument 404 errors/404

Options -Indexes +FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_URI} !/test\d?.php$
RewriteCond %{REQUEST_URI} !/test/.*$
RewriteCond %{REQUEST_URI} !/input.php$
RewriteRule !\.(css|jpg|js|gif|png|ico)$ dispatch.php[/quote]

The server already contained this code on it:

[quote]server {
server_name tools.eveuniversity.org;
root /var/www/tools;

location ~ \.php$ {
root /var/www/tools;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

index /index.php /index.html;

access_log /var/log/www/tools-access.log;
error_log /var/log/www/tools-error.log;
}
[/quote]

So I tried to add this above the index command:

[quote]error_page 401 errors/401
error_page 403 errors/403
error_page 404 errors/404

rewrite !\.(css|jpg|js|gif|png|ico)$ dispatch.php[/quote]

This didn't work (still forwarded to index.php). So I deleted the index command, and then instead got a 404 error (the server default). I tried changing the error_page info to 401.php, 403.php, 404.php but still got the server default error rather then my custom ones.

Basically, I'm not quite sure what I'm doing wrong or how to fix it. Hopefully someone can help.
Re: Need help converting htaccess to nginx commands
February 19, 2011 02:06AM
Small fix: the code the server already had had the index as:

index index.php index.html;
Sorry, only registered users may post in this forum.

Click here to login

Online Users

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