2012-07-10 305 views
0

所以我有博客在博客/忽略目录使用modrewrite

我想阻止yii(框架)重写博客/目录中的网址。

我该怎么做,使用modrewrite?

这里是我的.htaccessfile:

RewriteEngine on 
#RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$ 
#RewriteCond %{HTTPS}s ^on(s)| 
#RewriteRule^http%1://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 

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


# if a directory or a file exists, use it directly 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 

# otherwise forward it to index.php 
RewriteRule . index.php 

回答

1

加入这一行:

RewriteCond %{REQUEST_URI} !blog

例如:

RewriteEngine on 
RewriteCond %{REQUEST_URI} !blog 
#RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$ 
#RewriteCond %{HTTPS}s ^on(s)| 
#RewriteRule^http%1://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 

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


# if a directory or a file exists, use it directly 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 

# otherwise forward it to index.php 
RewriteRule . index.php 

这样,所有序贯规则将被应用如果请求网址与单词“博客”不匹配。