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.

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

报告相同问题?

悬赏问题

  • ¥35 这个的负序网络和零序网络怎么画?
  • ¥15 (标签-matlab)
  • ¥200 基于同花顺supermind的量化策略脚本编辑
  • ¥20 Html备忘录页面制作
  • ¥15 黄永刚的晶体塑性子程序中输入的材料参数里的晶体取向参数是什么形式的?
  • ¥20 数学建模来解决我这个问题
  • ¥15 计算机网络ip分片偏移量计算头部是-20还是-40呀
  • ¥15 stc15f2k60s2单片机关于流水灯,时钟,定时器,矩阵键盘等方面的综合问题
  • ¥15 YOLOv8已有一个初步的检测模型,想利用这个模型对新的图片进行自动标注,生成labellmg可以识别的数据,再手动修改。如何操作?
  • ¥30 NIRfast软件使用指导