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.
-
Possible duplicate of stackoverflow.com/questions/9669458/…John WH Smith– John WH Smith2014-04-03 18:17:04 +00:00Commented Apr 3, 2014 at 18:17
Add a comment
|
2 Answers
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 :)
5 Comments
Ignas
Now my URL is localhost/symfony/web/inbox, how can I fix it to drop that /web?
ponciste
try to edit
RewriteRule .? %{ENV:BASE}/app_dev.php [L] with RewriteRule .? %{ENV:BASE}/web/app_dev.php [L]ponciste
and put the
.htaccess on localhost/symfony not localhost/symfony/webIgnas
I can't do that, I get error. htaccess has to be in web folder. Error:
An error occurred while loading the web debug toolbar (404: Not Found). Do you want to open the profiler?ponciste
mh, i don't know that suggest you then, you have to try a little bit.. note that you'll have also to switch to
prod envroinment that will access to app.php not app_dev.php and when you'll put the project online you will probably work with linux, so you'll have do to it again on your server in which you can set DocumentRoot /var/www/Symfony/web. After that, this .htaccess will work fine. Consider what to do then, if you really need this to be working in local environmentEdit 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>
3 Comments
ponciste
then it still would be
domain.com/app.php/inbox ;)Anton Babenko
@ponciste it depends what is placed instead of
... something goes here ... in the config ;)Ignas
But if I'm working on few projects on my xampp server it might get uncomfortable. Btw later I'm planning to upload this code online, so there won;t be any apache configs.