2012-06-16 30 views
1

我Symfony2的運行在Windows7和XAMPP:如何改變htaccess的訪問symfony的網站目錄

http://localhost/symfony/web/app_dev.php/hello/symfony

如何更改網頁/ .htaccess文件通過下面的鏈接訪問symfony的?

http://localhost/app_dev.php/hello/symfony

默認的.htaccess是:

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^(.*)$ app.php [QSA,L] 

我嘗試添加Rewrite RewriteBase /symfony/web/RewriteBase symfony/web/然後php app/console cache:clear --env=prod --no-debug也試圖重新啓動Apache的。

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^(.*)$ app.php [QSA,L] 
RewriteBase /symfony/web/ OR RewriteBase symfony/web/ 

我可以在Nginx中使用反向代理嗎?如何改變訪問沒有symfony/web

+0

這是接近無研究工作。必須有教程/文檔。 –

+0

-1。沒有研究工作。 (抱歉)。歡迎來到stackowerflow! –

+0

@Olof Edler我是htaccess的新手,我在某處查了教程,但不知道htaccess的工作方式 – nickleefly

回答

0

嘗試添加127.0.0.1 www.mysymfony.com.localhost 到etc/hosts中添加 以下到httpd.conf中

# Be sure to only have this line once in your configuration<br> 
NameVirtualHost 127.0.0.1:80 

# This is the configuration for your project 
Listen 127.0.0.1:80 

<VirtualHost 127.0.0.1:80> 
    ServerName www.mysymfony.com.localhost 
    DocumentRoot "D:\xampp\htdocs\symfony\web" 
    DirectoryIndex app.php 
    <Directory "D:\xampp\htdocs\symfony\web"> 
    AllowOverride All 
    Allow from All 
    </Directory> 
</VirtualHost> 

訪問此鏈接 http://www.mysymfony.com.localhost/app_dev.php/demo/hello/symfony 它給出了一個錯誤,可是沒有這個環節

+0

'http:// www.symfony.localhost/demo/hello/symfony'應該可以工作。 –

+0

@ m2mdas實際上它不工作,我重新啓動Apache,甚至系統,它說沒有收到數據 無法加載網頁,因爲服務器沒有發送數據。 以下是一些建議: 稍後重新加載此網頁。 錯誤324(net :: ERR_EMPTY_RESPONSE):服務器關閉連接而不發送任何數據。 – nickleefly

+0

@ m2mdas修改httpd.conf和etc/hosts之後的舊鏈接[http://localhost/symfony/web/app_dev.php/demo/hello/symfony](http://localhost/symfony/web/app_dev.php/demo/hello/symfony)仍然有效 – nickleefly