2012-04-05 80 views
12

我試圖調整我的htacess文件以跳過重寫規則,如果文件或目錄存在,但是當文件存在時,它將URL更改爲不同的內容。我不知道爲什麼會發生這種情況。這裏是我的htaccess文件:如果文件或目錄存在,RewriteCond跳過規則

RewriteEngine On 

RewriteCond %{REQUEST_FILENAME} !-f [OR] 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^project/([^/\.]+)/?$ index.php?view=project&project=$1 [L] 
RewriteRule ^for/content/ag index.php?view=opening&section=ag [L] 
RewriteRule ^for/content/bus index.php?view=opening&section=bus [L] 
RewriteRule ^for/content/fcs index.php?view=opening&section=fcs [L] 
RewriteRule ^for/content/market index.php?view=opening&section=market [L] 
RewriteRule ^for/content/trade index.php?view=opening&section=trade [L] 
RewriteRule ^for/content/teched index.php?view=opening&section=teched [L] 
RewriteRule ^for/content/([^/\.]+)/?$ index.php?view=content_area&section=$1 [L] 

目錄/項目/ NTI存在,與index.php文件。輸入地址mywebsite.com/folder/project/nti後,它將更改爲mywebsite.com/folder/project/nti/?view=project & project = nti。我將這個應用於測試服務器上的示例站點位於子文件夾中,但實施時,它將位於根Web服務器文件夾中。

感謝您的幫助!

回答

25

刪除多餘[OR],有你這樣的代碼:

# If the request is not for a valid directory 
RewriteCond %{REQUEST_FILENAME} !-d 
# If the request is not for a valid file 
RewriteCond %{REQUEST_FILENAME} !-f 
# If the request is not for a valid link 
RewriteCond %{REQUEST_FILENAME} !-l 
RewriteRule ^project/([^/.]+)/?$ index.php?view=project&project=$1 [L,NC,QSA] 
相關問題