-1

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.

1

2 Answers 2

0

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 :)

Sign up to request clarification or add additional context in comments.

5 Comments

Now my URL is localhost/symfony/web/inbox, how can I fix it to drop that /web?
try to edit RewriteRule .? %{ENV:BASE}/app_dev.php [L] with RewriteRule .? %{ENV:BASE}/web/app_dev.php [L]
and put the .htaccess on localhost/symfony not localhost/symfony/web
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?
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 environment
0

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>

3 Comments

then it still would be domain.com/app.php/inbox ;)
@ponciste it depends what is placed instead of ... something goes here ... in the config ;)
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.