2013-05-30 49 views
0

我試圖重寫我的網站從.PHP爲.html的網址和我有與我想要做什麼干擾其他一些規則。如何從特定規則中排除特定的一組文件?

下面的代碼顯示了所有工作的規則,但我有一些扁平的PHP頁面,我想轉成html的網頁。一個例子是history.php history.html。

Options +FollowSymLinks -MultiViews 
# Turn mod_rewrite on 
RewriteEngine On 
RewriteBase/


##Vendor Pages 
RewriteRule ^([^/]+)/([^/]+)/([^.]+)\.html?$ vendors2.php?vendorslug=$3&locationslug=$1&categoryslug=$2 [L,QSA,NC] 

##Listing Pages 
RewriteRule ^([^/]+)/([^.]+)\.html?$ listings.php?locationslug=$1&categoryslug=$2 [L,QSA,NC] 

RewriteCond %{REQUEST_FILENAME}.php -f 
RewriteCond %{REQUEST_URI} !^(.*/)?history\.html$ [NC] 
RewriteRule ^([^/.]+)\.html?$ $1.php [L,NC] 

##Locations Pages 
RewriteRule ^([^/.]+)\.html?$ locations.php?locationslug=$1&Submit=Submit [L,QSA,NC] 

目前,該代碼會出現,因爲它試圖返回的頁面爲「位置頁」,因爲規則要與其他規則混淆。

有,我需要轉成html的(history.php,news.php,maps.php,resources.php,trivia.php等)幾頁。

任何建設性的幫助表示讚賞。

+0

我建議你打開改寫記錄... – arkascha

+0

arkascha,謝謝你的提示。我還沒有嘗試重寫日誌。我會閱讀它並嘗試它。再次感謝。 – NotJay

回答

1

這有可能是你根本不匹配的RewriteCond的。你RewriteCond檢查文件是否存在很可能被解釋爲,說:「是/home/username/public_html/history.html.php文件?」,這將失敗。

我會建議,而不是包括幾個RewriteCond是你的規則之前,你可以用一個單一的RewriteRule取代它,你##Locations Pages之前。像下面這樣:

RewriteRule (history|news|maps|resources)\.html $1.php [L] 

注意,這可能使一個過長...行,如果你有很多條目,所以你可以只將其分割成幾條規則。

如果你正在尋找的要求,在「根」是:

RewriteRule ^(history|news|maps|resources)\.html$ $1.php [L] 
+0

這工作正如我所需要的。非常感謝你!我感謝您的幫助。 – NotJay

相關問題