htaccess to nginx

DeineAgentur nginx-forum at nginx.us
Fri Jan 20 12:14:02 UTC 2012


Hey guys!

i have following htaccess but now i need it for nginx

can some one convert it correct to nginx so that ther are no security
risks?



ErrorDocument 404 /404.html
AddDefaultCharset utf-8
AddCharset utf-8 .html .php .css
Options FollowSymLinks

AddHandler application/x-httpd-php .html
<FilesMatch "\.(htm|html|php)$">
AddDefaultCharset UTF-8
# php_value auto_prepend_file
/home/webpages/lima-city/deineagentur/html/DeineAgentur/zip_output_header.php
</FilesMatch>

RewriteEngine On
# RewriteCond %{HTTP_HOST} !^oceangame\.deineagentur\.com$ [NC]
# RewriteRule ^(.*)$ http://oceangame.deineagentur.com/$1 [L,R=301]

RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK|OPTIONS|HEAD)$ [NC]
RewriteRule ^.*$ - [L,F]


####################
# URI redirections #
####################
# Move to www.example.com (we don't wanna serve this page without the
subdomain www)
RewriteCond %{HTTP_HOST} !^oceangame.deineagentur.com [NC]
RewriteRule ^.*$ http://oceangame.deineagentur.com%{REQUEST_URI}
[L,NC,R=301]
# If so, then load language defined by cookie
RewriteCond %{REQUEST_URI} ^/$
RewriteCond %{HTTP_COOKIE} lang=([a-z]{2})
RewriteRule ^.*$ /%1 [L,NC,QSA,R=301]
# Add a trailing slash to the request uri if /de was requested without
one
RewriteCond %{REQUEST_URI} ^/(de|en|fr|es|it)$
RewriteRule ^.*$ /%1/ [L,NC,QSA,R=301]

####################################
# Request the appropriate language #
####################################
# German
RewriteCond %{REQUEST_URI} ^/de(/)?$
RewriteRule ^de/?.*$ /system.php?og__site=index
[L,NC,QSA,E=LANGNAME:de,E=SYSTEM:portal]
RewriteCond %{REQUEST_URI} ^/de/([a-z]+).html$
RewriteRule ^de/([a-z]+).html$ /system.php?og__site=$1
[L,NC,QSA,E=LANGNAME:de,E=SYSTEM:portal]
# English
RewriteCond %{REQUEST_URI} ^/en(/)?$
RewriteRule ^en/?.*$ /system.php?og__site=index
[L,NC,QSA,E=LANGNAME:en,E=SYSTEM:portal]
RewriteCond %{REQUEST_URI} ^/en/([a-z]+).html$
RewriteRule ^en/([a-z]+).html$ /system.php?og__site=$1
[L,NC,QSA,E=LANGNAME:en,E=SYSTEM:portal]
# French
RewriteCond %{REQUEST_URI} ^/fr(/)?$
RewriteRule ^fr/?.*$ /system.php?og__site=index
[L,NC,QSA,E=LANGNAME:fr,E=SYSTEM:portal]
RewriteCond %{REQUEST_URI} ^/fr/([a-z]+).html$
RewriteRule ^fr/([a-z]+).html$ /system.php?og__site=$1
[L,NC,QSA,E=LANGNAME:fr,E=SYSTEM:portal]
# Spain
RewriteCond %{REQUEST_URI} ^/es(/)?$
RewriteRule ^es/?.*$ /system.php?og__site=index
[L,NC,QSA,E=LANGNAME:es,E=SYSTEM:portal]
RewriteCond %{REQUEST_URI} ^/es/([a-z]+).html$
RewriteRule ^es/([a-z]+).html$ /system.php?og__site=$1
[L,NC,QSA,E=LANGNAME:es,E=SYSTEM:portal]
# Italian
RewriteCond %{REQUEST_URI} ^/it(/)?$
RewriteRule ^it/?.*$ /system.php?og__site=index
[L,NC,QSA,E=LANGNAME:it,E=SYSTEM:portal]
RewriteCond %{REQUEST_URI} ^/it/([a-z]+).html$
RewriteRule ^it/([a-z]+).html$ /system.php?og__site=$1
[L,NC,QSA,E=LANGNAME:it,E=SYSTEM:portal]


########################
# Serving normal files #
########################
# Request language specific sitemap.xml
RewriteCond %{REQUEST_URI} ^/(de|en|fr|es|it)/sitemap.xml$
RewriteRule ^(de|en|fr|es|it)/.*$ /sitemap_$1.xml [L,NC]
# Request normal files like images or style sheets
RewriteCond %{IS_SUBREQ} false
RewriteRule ^(?:de|en|fr|es|it)/(.*)$ /$1 [L,NC,QSA,R=301]
# Move to index.php if the requested file doesn't exist
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ http://oceangame.deineagentur.com [L,NC,QSA,R=301]

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



More information about the nginx mailing list