2012-02-29 91 views
5

我一直在殴打我的头,整个晚上都无法看清我要出错的地方。我想在xampp上设置一个主机mysite.local,并按照所有说明操作,但我一直在重定向到mysite.local/xampp。xampp - mysite.local重定向到xampp文件夹

任何想法,我哪里会出错?的路径是正确的,我已经重新启动Apache的:)

我修改了hosts文件中加入:

127.0.0.1 mysite.local 

我编辑的额外/的httpd-vhosts.conf:

NameVirtualHost localhost:80 
<VirtualHost localhost:80> 
ServerName localhost 
DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs" 
<Directory "/Applications/XAMPP/xamppfiles/htdocs"> 
    Options Indexes FollowSymLinks MultiViews 
    AllowOverride all 
     Order Deny,Allow 
     Allow from all 
</Directory> 
</VirtualHost> 

<VirtualHost localhost:80> 
<Directory "/Applications/XAMPP/xamppfiles/htdocs/wd"> 
    Options Indexes FollowSymLinks MultiViews 
    AllowOverride all 
     Order Deny,Allow 
     Allow from all 
</Directory> 
    DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs/wd" 
    ServerName mysite.local 
</VirtualHost> 

回答

4

我昨天刚刚得到同样的问题。即使你做的步骤,在上下文中是正确的,你需要做一些更多的任务;) 您还需要编辑Apach'es httpd.conf参照新的虚拟主机是这样的:

# Your great site! 
<Directory "/Applications/XAMPP/xamppfiles/htdocs/wd"> 
    Options Indexes FollowSymLinks Includes ExecCGI 
    AllowOverride All 
    Order allow,deny 
    Allow from all 
</Directory> 

有了这个只有你自己将能够访问http://mysite.local而不重定向到XAMPP启动画面但是你会看到你的proyect的目录(至少如果你没有和索引在根文件夹中) 如果你需要加载一个文件一个文件夹(例如/public/index.php),您需要使用.htaccess文件。请记住,此文件必须位于您想要控制的文件夹中。因此,例如,一个.htaccess文件位于项目的根目录重定向到/public/index.php文件,则必须这样来做:

RewriteEngine On 
RewriteBase/
RewriteRule ^.*$ public/index.php [NC,L] 

只要记得用你所需要的正确的正则表达式,不要忘了在生产网站采取更安全的预防措施;)我希望我帮你了=)