2012-02-29 68 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] 

只要記得用你所需要的正確的正則表達式,不要忘了在生產網站採取更安全的預防措施;)我希望我幫你了=)