Jesus Jesus - 10 months ago 58
Apache Configuration Question

PHP symfony routing issues

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:

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

Answer Source

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.