我讀了這個問題:如何在子檔案夾中設定索引頁。我想做這樣的,我有這些檔案夾和檔案:
index.php
items/
items/index.php
我希望,當我搜索“items/general”時,items/index.php 會處理它,而不是 index.php。我試圖在 /items/.htacces 中創建一個 .htacces 檔案,如下所示:
RewriteEngine On
RewriteRule ^/?$ items/index.php [L]
但是當我搜索“專案/一般”時,它會給出 404 錯誤,如下所示:
Not Found
The requested URL was not found on this server.
(并且我的 items/index.php 包含將 html 發送到所有請求的代碼)
為什么它不起作用?
uj5u.com熱心網友回復:
你可以使用類似的東西:
RewriteRule items/ items/index.php [L]
如果你想要一個通用規則 /any-folder/any-file.php 到 /any-folder/index.php
RewriteRule (\w )/ $1/index.php [L]
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/459225.html
上一篇:HTACCESS-使用BrowserMatchNoCase阻止多個版本的過時瀏覽器(Chrome/Firefox)
