douzhao7445 2016-09-28 17:06
浏览 64
已采纳

PHP symfony路由问题

So I have a PHP website running in Symfony and I used XAMPP to setup apache and php. The website is nested under a few folders and it looks like this: C:\xampp\htdocs\company\PHP_Site\website\web

So my website URL is: http://localhost/company/PHP_Site/website/web

I have a .htaccess file that its rewriting URLs so they look pretty and dont have the .php at the end.

DirectoryIndex app.php

<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On

# Explicitly disable rewriting for front controllers
RewriteRule ^app_dev.php - [L]
RewriteRule ^app.php - [L]

RewriteCond %{REQUEST_FILENAME} !-f

# Change below before deploying to production
#RewriteRule ^(.*)$ /app.php [QSA,L]
RewriteRule ^(.*)$ app_dev.php [QSA,L]

I have rewrite enabled in my httpd.conf file and everything.

The problem I'm having is that some of the URLs that get generated are looking like this: http://localhost/cart instead of http://localhost/company/PHP_Site/website/web/cart

I have no idea what I'm doing wrong in my routing configuration. Please help

  • 写回答

1条回答 默认 最新

  • dongzhuo1498 2016-09-28 18:41
    关注

    As Cerad says, you need to set your DocumentRoot directive to point at C:\xampp\htdocs\company\PHP_Site\website\web rather than C:\xampp\htdocs\. Also, instead of that .htaccess file above, you should instead put:

    FallbackResource /app.php
    

    in the main server configuration - which does the same thing.

    .htaccess files are for people who don't have access to the server configuration file.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥60 Python如何后台操作Vmwake虚拟机键鼠
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容