Regex 阿帕奇公司;mod_rewrite-找不到索引
这可以根据需要工作,但Regex 阿帕奇公司;mod_rewrite-找不到索引,regex,apache,.htaccess,mod-rewrite,Regex,Apache,.htaccess,Mod Rewrite,这可以根据需要工作,但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/$
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]
选项MultiViews
由Apache的内容协商模块使用,该模块在mod_rewrite
之前运行,并使Apache服务器匹配文件扩展名。所以/file
可以在URL中,但它将提供/file.php