首页 文章

如何更改htaccess以访问symfony web目录

提问于
浏览
1

我在Windows7和Xampp中运行symfony2:

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

如何使用下面的链接更改web / .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 的情况下更改访问权限?

1 回答

  • 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 它给出了一个错误,没有这个链接

相关问题