繁体   English   中英

Apache&mod_rewrite-找不到索引

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM