So I have this question: I have a web application on xampp. Now my URL is: localhost/symfony/web/app_dev.php/inbox
But I want it to be just localhost/inbox
for example. Is that possible? I only know the way to do it with nginx, but not with the xampp or symfony routing.
you have do edit the .htaccess
you can use this one and put in on localhost/symfony/web
:
DirectoryIndex app_dev.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^app_dev\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule .? - [L]
RewriteRule .? %{ENV:BASE}/app_dev.php [L]
</IfModule>
<IfModule !mod_rewrite.c>
<IfModule mod_alias.c>
RedirectMatch 302 ^/$ /app_dev.php/
# RedirectTemp cannot be used instead
</IfModule>
</IfModule>
PS: your URL will be localhost/symfony/inbox
as it should be. Then when you'll put it on a server, you'll put all the files in the root and your URL will be domain.com/inbox
hope this helps :)
Edit your Apache config file to point DocumentRoot
correctly to web
folder:
DocumentRoot /var/www/Symfony/web
<Directory /var/www/Symfony/web>
... something goes here ...
</Directory>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.