Welcome! Log In Create A New Profile

Advanced

Re: Help with convert .htaccess to nginx

April 12, 2012 09:47PM
I want convert htaccess to nginx, .htaccess file content:

# If the file is NOT the index.php file
<IfModule mod_rewrite.c>

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !index.php
# Hide all PHP files so none can be accessed by HTTP
RewriteRule (.*)\.php$ index.php/$1


RewriteCond $1 !^(index\.php|nhototamsu|assets|cache|xd_receiver\.html|photo|ipanel|automap|xajax_js|files|robots\.txt|favicon\.ico|ione\.ico|(.*)\.xml|ror\.xml|tool|google6afb981101589049\.html|googlec0d38cf2adbc25bc\.html|widget|iradio_admin|services|wsdl)

RewriteRule ^(.*)$ index.php/$1 [QSA,L]



</IfModule>



I convert to nginx:


if ($request_filename !~ "index.php") {
rewrite /(.*).php$ /index.php/$1;
}
if ($request_uri !~ "^(index\.php|nhototamsu|assets|cache|xd_receiver\.html|photo|ipanel|automap|xajax_js|files|robots\.txt|favicon\.ico|ione\.ico|(.*)\.xml|ror\.xml|tool|google6afb981101589049\.html|googlec0d38cf2adbc25bc\.html|widget|iradio_admin|services|wsdl)") {
rewrite ^/(.*)$ /index.php/$1 last;
}


and nginx.conf file content:

worker_processes 4;
error_log logs/error.log debug;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
include /etc/nginx/conf.d/*;
sendfile on;
server_tokens off;
keepalive_timeout 15;

proxy_buffering off;

client_body_buffer_size 128K;
client_header_buffer_size 1k;
client_max_body_size 20m;
large_client_header_buffers 2 1k;

client_body_timeout 10;
client_header_timeout 10;
send_timeout 10;

gzip on;
gzip_comp_level 2;
gzip_min_length 1000;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain application/xml;
gzip_disable "MSIE [1-6]\.";
server {
listen 80;
server_name ione.net;
root /www/ione/virtual;
if ($request_filename !~ "index.php") {
rewrite /(.*).php$ /index.php/$1;
}
if ($request_uri !~ "^(index\.php|nhototamsu|assets|cache|xd_receiver\.html|photo|ipanel|automap|xajax_js|files|robots\.txt|favicon\.ico|ione\.ico|(.*)\.xml|ror\.xml|tool|google6afb981101589049\.html|googlec0d38cf2adbc25bc\.html|widget|iradio_admin|services|wsdl)") {
rewrite ^/(.*)$ /index.php/$1 last;
}
location / {
index index.php index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~* "\.(js|ico|gif|jpg|png|css|html|htm|swf|htc|xml|bmp|cur)$" {
add_header Pragma "public-static";
add_header Cache-Control "public-static";
expires 3M;
access_log off;
log_not_found off;
}
location ~* \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
}
location ~ /\. {
access_log off;
log_not_found off;
deny all;
}
}
}
Subject Author Posted

Help with convert .htaccess to nginx

haonhien April 11, 2012 11:19PM

Re: Help with convert .htaccess to nginx

Jonathan Matthews April 12, 2012 07:32AM

Re: Help with convert .htaccess to nginx

haonhien April 12, 2012 09:47PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 77
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready