2014-01-30 59 views
4

现在我已经很长时间在摸索它了。无法设法让它工作。 (我是apache的noob,可能也是其中一个原因)。好的,这里简单来说就是问题。我正在使用wamp,我有一个目录Retailer。里面还有另一个名为public的目录,其中包含索引和其他文件。我想使这个目录文件根为public。我想与.htaccess在wamp上使用.htaccess更改文档根目录

apache的我的重写模块打开。

这是我曾尝试:

RewriteEngine on 
RewriteBase /public/ 
RewriteRule ^index.php$ test.php 

而且我也试过

RewriteEngine on 
RewriteCond %{HTTP_HOST} ^localhost/Retailer$ [NC,OR] 
RewriteCond %{HTTP_HOST} ^localhost/Retailer$ 
RewriteCond %{REQUEST_URI} !public/ 
RewriteRule (.*) /public/$1 [L] 

我试图

RewriteEngine on 
RewriteCond %{HTTP_HOST} ^http://localhost/Retailer/$ [NC,OR] 
RewriteCond %{HTTP_HOST} ^http://localhost/Retailer/$ 
RewriteCond %{REQUEST_URI} !public/ 
RewriteRule (.*) /public/$1 [L] 

但导致在所有这些情况是一样的。那就是: enter image description here

任何帮助将不胜感激 艾哈迈尔

+0

? –

+0

否我想要使用.htaccess更改文档根目录 –

+0

此更改后要使用的URL是什么? – anubhava

回答

4

使用此规则在Retailer/.htaccess文件

RewriteEngine on 
RewriteBase /Retailer/ 

RewriteRule ^((?!public/).*)$ public/$1 [L,NC] 
要创建WAMP虚拟主机
+0

哦,不,它吸脏了黑客! – Oleg

3

您应该配置此不.htaccess文件,但在Apache的配置文件httpd.conf

<VirtualHost 127.0.0.1:80> 
    DocumentRoot "/path/to/project/Retailer/public" 
    ServerName "retailer.local" 
    ServerAlias "www.retailer.local" 
</VirtualHost> 

另外你需要更新你的hosts文件与下一行:

127.0.0.1 retailer.local 

并重新启动您的网络服务器!

+2

并重新启动您的网络服务器! –

+1

当然,谢谢:-) – Oleg