Welcome! Log In Create A New Profile


YA Converting .htaccess to nginx, I can't get it to work!

February 04, 2013 10:23PM
Hi all,
I am trying to convert this htaccess file to nginx config and it is not working.
Here is my .htaccess

<IfModule mod_headers.c>
Header unset ETag
FileETag None
<FilesMatch "(?i)^.*\.(ico|flv|jpg|jpeg|png|gif|js|css)$">
Header unset Last-Modified
Header set Expires "Fri, 21 Dec 2020 00:00:00 GMT"
Header set Cache-Control "public, no-transform"

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^((.)?)$ index.php?p=home [L]

RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.*)$ $1 [QSA,L]

RewriteCond $1 !^(\#(.)*|\?(.)*|\.htaccess(.)*|\.htaccess\.back(.)*|.idea\/(.)*|.svn\/(.)*|admin\.php(.)*|content\/(.)*|download\.php(.)*|ecc\/(.)*|images\/(.)*|index\.php(.)*|install\/(.)*|login\.php(.)*|readme\.txt(.)*|robots\.txt(.)*)
RewriteRule ^(.+)$ index.php?url=$1&%{QUERY_STRING} [L]

<IfModule mod_deflate.c>
<FilesMatch "\.(js|css|ico|flv|jpg|jpeg|png|gif)$">
SetOutputFilter DEFLATE

and here is my config. I can get it to somewhat work if I only use one of the following lines but then the rest is broke!

location / {
if ($query_string ~ "^$"){
rewrite ^/((.)?)$ /index.php?p=home break;
if (-e $request_filename){
rewrite ^(.*)$ /$1 break;
rewrite ^(.+)$ /index.php?url=$1&$query_string break;
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/tmp/php5-fpm.sock;
fastcgi_index index.php;
include /etc/nginx/fastcgi_params;


Not to mention that I hate using the if else clauses in my nginx config because I think I read where it is poor for performance.

Can someone give me a hand here. I have been working on this for hours without any luck.
Subject Author Posted

YA Converting .htaccess to nginx, I can't get it to work!

otherjohn February 04, 2013 10:23PM

Sorry, only registered users may post in this forum.

Click here to login

Online Users

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