![](/img/trans.png)
[英]Apache mod_rewrite rule for complex sitemap + index xml files
[英]Apache & mod_rewrite - index not found
這可以按需工作,除了index
或“索引目錄”中的任何內容(例如index/foo
將失敗。
RewriteEngine on
# base dir
RewriteBase /project/
# allow assets/ directory
RewriteRule ^(assets)/(.*)$ $0 [L]
# direct all else to index.php
RewriteCond $1 !^(index\.php)
RewriteRule ^(.*)$ index.php/$1?%{QUERY_STRING} [L]
我已經嘗試過了,但是仍然無法解決:
RewriteRule ^index(/.*)?$ index.php/$1?%{QUERY_STRING} [L]
試試這個代碼:
Options -MultiViews
RewriteEngine on
# base dir
RewriteBase /project/
# allow assets/ directory
RewriteRule ^(assets)/(.*)$ $0 [L]
# direct all else to index.php
RewriteRule ^((?!index\.php$).*)$ index.php/$1 [L,NC]
Apache's content negotiation module
使用Option MultiViews
,該Apache's content negotiation module
在 mod_rewrite
之前運行,並使Apache服務器匹配文件擴展名。 因此/file
可以位於URL中,但它將提供/file.php
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.