将.htacces转换为nginx

时间:2016-08-26 12:05:37

标签: nginx

我正在尝试将.htaccess规则转换为nginx。

RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]

RewriteCond %{HTTP_USER_AGENT} (android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge\ |maemo|midp|mmp|netfront|opera\ m(ob|in)i|palm(\ os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows\ (ce|phone)|xda|xiino [NC,OR]
RewriteCond %{HTTP_HOST} ^(m\.pet\.lyd\.co\.kr|m\.com)
RewriteCond %{REQUEST_URI} !^/uploads/.*
RewriteRule (.*) /m/$2 [L]

RewriteRule ^/?xlab(.*) $1?%{QUERY_STRING} [R]
RewriteRule ^/?content/([0-9]+)$ /content.php?idxContent=$1
RewriteRule ^/?content/view/([0-9]+)$ /content/view/?id=$1
RewriteRule ^/?contentForKakao/([0-9]+)$ /contentForKakao.php?idxContent=$1
RewriteRule ^/?contentForTwitter/([0-9]+)$ /contentForTwitter.php?idxContent=$1
RewriteRule ^/?notifications/?$ /notifications/index.php
RewriteRule ^/?welcomenote/?$ /welcomenote/index.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} ^\/(auth|profile|company|search|page|lab|post|notification|admin|group|question)\/?.*

RewriteRule ^ index.php [L]

配置的一小部分我已经完成了,但接下来我被卡住了。

server {
    listen      80;
    server_name www.example.com;
    root /var/www/example/;

    rewrite ^  http://exmaple.com$request_uri permanent;

        location / {
    try_files $uri $uri/ /index.php?a=$uri; }

请求帮助。

感谢。

0 个答案:

没有答案