這是我的目錄結構:
- parent
- child-folder-1
index.php
- child-folder-2
index.php
.htaccess
我希望當我訪問example.com它時應該index.php從child-folder-1目錄加載檔案,當我點擊example.com/xyz它時應該加載index.php來自child-folder-2.
我的.htaccess檔案的內容應該是什么?
uj5u.com熱心網友回復:
假設example.com是唯一指向您帳戶的域,那么您不需要在規則中明確檢查這一點,因此您可以.htaccess使用 mod_rewrite在根檔案中執行以下操作:
RewriteEngine On
RewriteRule ^$ child-folder1/index.php [L]
RewriteRule ^xyz$ child-folder2/index.php [L]
請注意,如果您的.htaccess檔案中有現有指令,則指令的順序可能很重要。這些重寫需要在任何規范重定向之后進行。
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/317898.html
