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.

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

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效