Rewrite rule for nginx from Apache

the_traveller nginx-forum at nginx.us
Fri May 13 03:59:15 MSD 2011


Please can you help me to convert this to nginx

<IfModule mod_rewrite.c>
RewriteEngine on

# If you are having problems or are using VirtualDocumentRoot, uncomment
this line and set it to your  directory.
# RewriteBase /maindir/
RewriteOptions MaxRedirects=30
RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule .* - [L]


RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d

RewriteRule ^.*$ - [NC,L]

RewriteRule ^index(.*)$                                      index.php
[QSA]
RewriteRule ^chat/.*                                         pages.php
[QSA]
RewriteRule ^Songs(.*)$                                     
showcat.php?g=2 [QSA]
RewriteRule ^Jokes(.*)$                                     
showcat.php?g=3 [QSA]
RewriteRule ^Ash3ar(.*)$                                    
showcat.php?g=4 [QSA]
RewriteRule ^iraq/.*                                        showcat.php 
   [QSA]
RewriteRule ^Song/.*                                         sounds.php 
    [QSA]
RewriteRule ^Joke/.*                                         jokes.php  
    [QSA]
RewriteRule ^Poem/.*                                         poems.php  
    [QSA]
RewriteRule ^link/.*                                         advs.php   
    [QSA]
RewriteRule ^search/.*                                       search.php 
    [QSA]
RewriteRule ^adv-conditions(.*)$                                
ad.php?go=conditions      [NC]
RewriteRule ^adv-payments(.*)$                                  
ad.php?go=payments      [NC]

RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d

RewriteRule ^.*$ - [NC,L]
RewriteRule ^(?:(.*?)(?:/|$))(.*|$)$ $1.php?r=$2 [QSA]


</IfModule>


<IfModule mod_security.c>
   SecFilterEngine Off
   SecFilterScanPOST Off
</IfModule>

<IfModule mod_gzip.c>
mod_gzip_on No
</IfModule>

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,23868,197702#msg-197702




More information about the nginx mailing list