2012-07-10 295 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 

這樣,所有序貫規則將被應用如果請求網址與單詞「博客」不匹配。