.htaccess rewriterule不重定向特定网址

时间:2013-01-30 07:26:50

标签: .htaccess rewrite

我写了重写url的规则

RewriteRule ^([a-zA-Z0-9-/]+)$ news.php?id=$1
RewriteRule ^([a-zA-Z0-9-/]+)/$ news.php?id=$1

但我需要http://mysite.com/blog/不要被这些规则重写。 谢谢你的建议:)。

我的.htaccess文件:

RewriteEngine On 
RewriteBase / 
RewriteCond %{REQUEST_URI} !news\.php [NC] 
RewriteCond %{REQUEST_URI} !/blog [NC] 
RewriteCond %{REQUEST_URI} ^/([^/]+) [NC] 
RewriteRule .* news.php?id=%1 [R=301,L] 
RewriteRule ^video_([^/]+) video.php?page=Video&table=$1 
RewriteRule ^en/([a-zA-Z0-9-/]+)$ en/news_en.php?no=$1 
RewriteRule ^en/([a-zA-Z0-9-/]+)/$ en/news_en.php?no=$1 
RewriteRule ^it/([a-zA-Z0-9-/]+)$ it/news.php?id=$1 
RewriteRule ^it/([a-zA-Z0-9-/]+)/$ it/news.php?id=$1 

RewriteRule ^photo_([^/]+) photogalery.php?page=Photo&part=$1 
RewriteRule ^en/photo_([^/]+) en/photogalery.php?page=Photo&part=$1 
RewriteRule ^it/photo_([^/]+) it/photogalery.php?page=Photo&part=$1 
ErrorDocument 404 /404.html 

1 个答案:

答案 0 :(得分:0)

使用

RewriteEngine On
RewriteRule ^blog/([a-zA-Z0-9_-]+)$ news.php?id=$1