phpmotion rewriterule htaccess重写nginx

时间:2011-09-18 07:52:10

标签: .htaccess nginx rewrite

需要帮助转换.htaccess phpmotion来重写nginx。试图转换但不能在我的盒子上工作。

RewriteBase /
RewriteRule \.(css|jpe?g|gif|png|flv|swf)$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Main Menu Links #
RewriteRule ^videos/load/([^/]*)$ seemore.php?load=$1 [L]
RewriteRule ^videos/load/([^/]*)/([^/]*)$ seemore.php?load=$1&page=$2 [L]

RewriteRule ^audios/load/([^/]*)$ audio.php?load=$1 [L]
RewriteRule ^audios/load/([^/]*)/([^/]*)$ audio.php?load=$1&page=$2 [L]

RewriteRule ^audio/album/([^/]*)/([^/]*)$ audio.php?album=$1 [L]
RewriteRule ^audio/album/([^/]*)/([^/]*)/([^/]*)$ audio.php?album=$1&page=$3 [L]

RewriteRule ^blogs/load/([^/]*)$  blogs.php?load=$1 [L]
RewriteRule ^blogs/load/([^/]*)/([^/]*)$ blogs.php?load=$1&page=$2 [L]

RewriteRule ^albums/load/([^/]*)$ albums.php?load=$1 [L]
RewriteRule ^albums/([^/]*)/([^/]*)$ albums.php?load=$1&page=$2 [L]

RewriteRule ^people_ajax people_ajax.php [L]
RewriteRule ^people/([^/]*)/([^/]*)$ people.php?load=$1&page=$2 [L]
RewriteRule ^people people.php [L]
RewriteRule ^upload-media upload.php [L]

RewriteRule ^groups$ groups.php [L]
RewriteRule ^search search.php [L]


# Action Links #
RewriteRule ^videos/([^/]*)/([^/]*)$ play.php?vid=$1 [L]
RewriteRule ^audio/([^/]*)/([^/]*)$ play_audio.php?audio=$1

RewriteRule ^category/([^/]*)$ category_home.php?cid=$1 [L]
RewriteRule ^category/([^/]*)/([^/]*)$ category_home.php?cid=$1&page=$2 [L]

RewriteRule ^subcategory/([^/]*)/([^/]*)$ category_home.php?sub=$1 [L]
RewriteRule ^subcategory/([^/]*)/([^/]*)/([^/]*)$ category_home.php?sub=$1&page=$3 [L]

RewriteRule ^genre/([^/]*)$ genre_home.php?cid=$1 [L]
RewriteRule ^genre/([^/]*)/([^/]*)$ genre_home.php?cid=$1&page=$2 [L]

RewriteRule ^view-album/([^/]*)/([^/]*)$ album_view.php?album=$1
RewriteRule ^view-image/([^/]*)/([^/]*)$ album_view.php?image=$1
RewriteRule ^read_blog/([^/]*)/([^/]*)$ read_blog.php?id=$1 [L]

RewriteRule ^blogs/category/([^/]*)/([^/]*)$ blogs.php?cat_id=$1 [L]
RewriteRule ^blogs/category/([^/]*)/([^/]*)/([^/]*)$ blogs.php?cat_id=$1&page=$3 [L]

RewriteRule ^members/([^/]*)$  memberprofile.php?user=$1 [L]

#-------------------------------------------------------------#
# redirect directory browsing attempts
RewriteRule ^videos(.?)$    seemore.php [L]
RewriteRule ^audios(.?)$    audio.php   [L]
RewriteRule ^blogs(.?)$     blogs.php   [L]
RewriteRule ^members(.?)$   people  [R=301]
RewriteRule ^albums(.?)$    albums.php [L]


RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
RewriteCond %{QUERY_STRING} SELECT(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} UNION(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteRule ^(.*)$ index.php [F,L

尝试从convert-apache-htaccess-to-nginx转换重写

不会工作

1 个答案:

答案 0 :(得分:1)

你在这里

if (!-f $request_filename)
{
set $rule_1 1$rule_1;
}
if (!-d $request_filename)
{
set $rule_1 2$rule_1;
}
if ($rule_1 = "21")
{
rewrite ^/videos/load/([^/]*)$ /seemore.php?load=$1 last;
}
rewrite ^/videos/load/([^/]*)/([^/]*)$ /seemore.php?load=$1&page=$2 last;
rewrite ^/audios/load/([^/]*)$ /audio.php?load=$1 last;
rewrite ^/audios/load/([^/]*)/([^/]*)$ /audio.php?load=$1&page=$2 last;
rewrite ^/audio/album/([^/]*)/([^/]*)$ /audio.php?album=$1 last;
rewrite ^/audio/album/([^/]*)/([^/]*)/([^/]*)$ /audio.php?album=$1&page=$3 last;
rewrite ^/blogs/load/([^/]*)$ / last;
rewrite ^/blogs/load/([^/]*)/([^/]*)$ /blogs.php?load=$1&page=$2 last;
rewrite ^/albums/load/([^/]*)$ /albums.php?load=$1 last;
rewrite ^/albums/([^/]*)/([^/]*)$ /albums.php?load=$1&page=$2 last;
rewrite ^/people_ajax /people_ajax.php last;
rewrite ^/people/([^/]*)/([^/]*)$ /people.php?load=$1&page=$2 last;
rewrite ^/people /people.php last;
rewrite ^/upload-media /upload.php last;
rewrite ^/groups$ /groups.php last;
rewrite ^/search /search.php last;
rewrite ^/videos/([^/]*)/([^/]*)$ /play.php?vid=$1 last;
rewrite ^/audio/([^/]*)/([^/]*)$ /play_audio.php?audio=$1;
rewrite ^/category/([^/]*)$ /category_home.php?cid=$1 last;
rewrite ^/category/([^/]*)/([^/]*)$ /category_home.php?cid=$1&page=$2 last;
rewrite ^/subcategory/([^/]*)/([^/]*)$ /category_home.php?sub=$1 last;
rewrite ^/subcategory/([^/]*)/([^/]*)/([^/]*)$ /category_home.php?sub=$1&page=$3 last;
rewrite ^/genre/([^/]*)$ /genre_home.php?cid=$1 last;
rewrite ^/genre/([^/]*)/([^/]*)$ /genre_home.php?cid=$1&page=$2 last;
rewrite ^/view-album/([^/]*)/([^/]*)$ /album_view.php?album=$1;
rewrite ^/view-image/([^/]*)/([^/]*)$ /album_view.php?image=$1;
rewrite ^/read_blog/([^/]*)/([^/]*)$ /read_blog.php?id=$1 last;
rewrite ^/blogs/category/([^/]*)/([^/]*)$ /blogs.php?cat_id=$1 last;
rewrite ^/blogs/category/([^/]*)/([^/]*)/([^/]*)$ /blogs.php?cat_id=$1&page=$3 last;
rewrite ^/members/([^/]*)$ /memberprofile.php?user=$1 last;
rewrite ^/members/([^/]*)$ /;
rewrite ^/videos/(.?)$ /seemore.php last;
rewrite ^/audios/(.?)$ /audio.php;
rewrite ^/blogs/(.?)$ /blogs.php;
rewrite ^/members/(.?)$ people permanent;
rewrite ^/albums/(.?)$ /albums.php last;
if ($args ~* "(\|%3E)"){
set $rule_36 1;
return 403;
break;
}
if ($args ~ "GLOBALS(=|\[|\%[0-9A-Z]{0,2})"){
set $rule_36 1;
return 403;
break;
}
if ($args ~ "_REQUEST(=|\[|\%[0-9A-Z]{0,2})"){
set $rule_36 1;
return 403;
break;
}
if ($args ~ "SELECT(=|\[|\%[0-9A-Z]{0,2})"){
set $rule_36 1;
return 403;
break;
}
if ($args ~ "UNION(=|\[|\%[0-9A-Z]{0,2})"){
set $rule_36 1;
return 403;
break;
}