2012-06-16 31 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