繁体   English   中英

Apache mod_rewrite将链接重定向到localhost。 如何使.htaccess与本地计算机中的每个站点一起使用?

[英]Apache mod_rewrite redirects links to localhost. How to make .htaccess to work with each site in local machine?

我已经将Xampp安装为Web服务器,并希望为我的一个项目创建干净的URL。 因此,我将这些简单的行放在此项目根目录的.htaccess文件中:

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

我在这个项目中也做了这样的链接:

<a href="/about/">About Us</a>

我希望去localhost / this_project / about / ,但是不起作用。 我去localhost / about / ,这是错误的。 我怎么解决这个问题?

我还将这一行放在.htaccess文件的第二行中,但是没有发生任何变化。

RewriteBase /this_project/

注意:每个项目的htdocs文件夹中都有许多目录。

您的htaccess看起来还不错,所以我想您不见了

AllowOverride All

在VHOST <directory>块中。 如果在添加AllowOverride之后服务器将失败,请确保启用了mod_rewrite。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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