Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.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 .htaccess重写规则将驱动器路径添加到URL_Apache_.htaccess_Mod Rewrite_Apache2 - Fatal编程技术网

Apache .htaccess重写规则将驱动器路径添加到URL

Apache .htaccess重写规则将驱动器路径添加到URL,apache,.htaccess,mod-rewrite,apache2,Apache,.htaccess,Mod Rewrite,Apache2,我正在使用安装在Win7机器上C:上的Zend Server CE v.5.1.0。我通过添加以下内容向httpd.conf添加了一个项目: Alias /project "D:\Homepages\project" <Directory "D:\Homepages\project"> Options Indexes FollowSymLinks AllowOverride all Order allow,deny Allow from all <

我正在使用安装在Win7机器上C:上的Zend Server CE v.5.1.0。我通过添加以下内容向httpd.conf添加了一个项目:

Alias /project "D:\Homepages\project"
<Directory "D:\Homepages\project">
    Options Indexes FollowSymLinks
    AllowOverride all
    Order allow,deny
    Allow from all
</Directory>
现在来谈谈这个问题;如果我去

一切似乎都很顺利。我访问index.php文件并获取我的内容。 但是,如果我转到任何其他会触发重写规则的页面,它似乎在添加目录路径。FireFox输出以下未找到消息:

在此服务器上找不到请求的URL/Homepages/project/index.php

我试图在这里找到类似的问题/答案,但失败了。有什么想法吗?
另外,由于我要出差一段时间,我接受答复的时间可能会推迟。

最后一句话是这样的:

RewriteRule ^.*$ /index.php [NC,L]
然而,我认为这是一个无限循环,因此我建议使用以下规则:

RewriteCond %{THE_REQUEST} !\s/index.php [NC]
RewriteCond %{REQUEST_URI} !^/index.php [NC]
RewriteRule . /index.php [L]

如果index.php已经是/index.php,它将阻止进入index.php。

您需要设置RewriteBase指令;否则,mod_rewrite会自动执行,默认情况下,会将文件路径前置到生成的重写规则

发件人:

当替换新URL时,此模块必须将URL重新注入服务器处理。要做到这一点,它需要知道相应的URL前缀或URL基是什么。默认情况下,此前缀是相应的文件路径本身。然而,对于大多数网站来说,URL与物理文件名路径没有直接关系,所以这种假设通常是错误的!因此,可以使用RewriteBase指令指定正确的URL前缀。 如果Web服务器的URL与物理文件路径没有直接关系,则需要在每个要使用RewriteRule指令的.htaccess文件中使用RewriteBase


对不起,我的第一篇帖子说一切顺利。事实并非如此。直接去的时候感觉很好,谢谢你的回答!然而,这对我不起作用。您的解决方案似乎重定向到,而不是。当然,我可以把它改成重写规则/project/index.php[L],但我不希望将路径硬编码到.htaccess文件中,我将。。很抱歉在评论完成之前发布了这篇文章
RewriteCond %{THE_REQUEST} !\s/index.php [NC]
RewriteCond %{REQUEST_URI} !^/index.php [NC]
RewriteRule . /index.php [L]