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.

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

报告相同问题?

悬赏问题

  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵