Apache .htaccess将所有请求重定向到index.php
所以我想设置一些东西,以便所有请求都通过index.php 一些谷歌搜索给了我这个修改Apache .htaccess将所有请求重定向到index.php,apache,.htaccess,Apache,.htaccess,所以我想设置一些东西,以便所有请求都通过index.php 一些谷歌搜索给了我这个修改 <IfModule mod_rewrite.c> RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !(index\.php|public|css|js|robots\.txt) RewriteRule ^
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !(index\.php|public|css|js|robots\.txt)
RewriteRule ^ index.php [L,QSA]
</IfModule>
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写cond%{REQUEST_FILENAME}!(索引\.php | public | css | js | robots\.txt)
重写规则^index.php[L,QSA]
这很有效。但是,如果我真的点击了index.php,我不希望它运行。
所以
我希望www.domain/test被视为www.domain/index.php/test,确实如此
但如果我在浏览器中点击www.domain/index.php/test,它也会做同样的事情,但它会重定向到某个主文件夹
我还读到,我不希望这种重定向发生在css、js和机器人上
如何使规则不为index.php做任何事情?这应该可以
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|public|css|js|robots\.txt|test)
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
1美元^(索引\.php | public | css | js | robots\.txt | test)
重写规则^(.*)$index.php/$1[L]
。。。你不是已经这么做了吗<代码>重写cond%{REQUEST_FILENAME}-f--“如果文件不存在…”不起作用。domain/test完全停止工作(未指定输入文件),domain/index.php/test仍执行与以前相同的操作。如果您有一个文件夹名测试,请将其添加到条件中,再次查看我的答案,并让我知道它不起作用。请设法使它与我的原始答案一起工作。结果发现错误就在index.php本身内部。无论如何谢谢你的帮助