Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
apache mod_重写为force index.php_Apache_Mod Rewrite - Fatal编程技术网

apache mod_重写为force index.php

apache mod_重写为force index.php,apache,mod-rewrite,Apache,Mod Rewrite,我在拔头发 如果%{REQUEST\u URI}不是现有文档,我将使用mod_rewrite运行index.php: #Any request (page) which doesnt exist (item pages, special urls, categories etc) #get routed through urlparse, where PHP takes over nicely RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f Rewr

我在拔头发

如果%{REQUEST\u URI}不是现有文档,我将使用mod_rewrite运行index.php:

#Any request (page) which doesnt exist (item pages, special urls, categories etc)
#get routed through urlparse, where PHP takes over nicely
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteRule (.*) urlparse.php?url=$1 [L]
考虑到这一点,我希望在此之前有一条规则规定:

if %{REQUEST_URI} is empty then pretend it is index.php
我的理解是像这样的url

http://www.server.com/
那么%{REQUEST_URI}是“”(一个空字符串),第

其中%{REQUEST_URI}是“某物/任何东西”

谢谢你们的帮助。

简单地说:

RewriteRule ^$ index.php

难道没有办法告诉apache使用index.php作为404文档吗?如果不重写,这对您来说不是很好吗?是的,但是对于这个没有帮助的特殊情况,其中一个类别实际上匹配了一个空字符串(“Shoes”是类别,因为mysql中的“Shoes”url是“”(空字符串)。如果%{REQUEST_URI}为空,我希望通过强制index.php来坚决避免这种情况。非常感谢。我不得不在规则中添加[L]以强制apache不解析其他规则,但您已经缓解了我的压力头痛。
RewriteRule ^$ index.php