1
我有以下.htaccess
服務的一切index.php
,並防止.txt
顯示靜態文件。htaccess重寫多個條件
我想添加只需一個附加規則:重定向example.com/re
至example.com/re.php
。這個怎麼做?
這失敗了,我不知道爲什麼:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^re$ re.php //fail: style.css won't be accessible anymore, leading to broken website
RewriteRule ^(.*)$ index.php [QSA,L]
RewriteRule \.txt$ index.php [L]
嘿@basj檢查這個問題:[here](https://stackoverflow.com/questions/17048796/htaccess-add-php-to-everything-without-an-extension-already) - 類似問題,回答可能會幫助你。 – Lag
@thickguru我花了最後30分鐘,但仍然無法使它工作。當我在任何地方插入'RewriteRule^re $ re.php [L]'時,它會打破一切,並使style.css被破壞。 – Basj
RewriteCond僅影響直接跟隨的RewriteRule。所以,只要在這些之後直接插入一條不同的規則,就可以從根本上改變整個事情。根據您最新的評論,您使用的[L]標誌在您的問題中顯示的代碼中缺失。 – CBroe