![](/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.