0

What i Have

What i want

Remove /web/app_dev.php from url.

What have i tried so far

When i go to http://www.example.com/~araymond/portfolio/home, i encounter the following error:

No route found for "GET /~araymond/portfolio/home"
404 Not Found - NotFoundHttpException


Here is my portfolio/.htaccess :

RewriteEngine on
RewriteBase /~araymond/portfolio/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# DEV ENVIRONMENT #
RewriteRule ^$ web/app_dev.php [QSA]
RewriteRule ^(.*)$ web/app_dev.php/$1 [QSA,L]


Here is my portfolio/web/.htaccess:

DirectoryIndex app.php

<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
    RewriteRule ^(.*) - [E=BASE:%1]

    RewriteCond %{ENV:REDIRECT_STATUS} ^$
    RewriteRule ^app\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]

    RewriteCond %{REQUEST_FILENAME} -f
    RewriteRule .? - [L]

    # Rewrite all other queries to the front controller.
    RewriteRule .? %{ENV:BASE}/app.php [L]
</IfModule>

<IfModule !mod_rewrite.c>
    <IfModule mod_alias.c>
        RedirectMatch 302 ^/$ /app.php/
    </IfModule>
</IfModule>

I can't find any solutions that allow me to remove the /web/app_dev.php part.

1

2 Answers 2

3

Is there reason why you want to do this with .htaccess? You could just use symbolic link? All you have to do is to rename that portfolio folder and create symbolic link that maps to web folder. Then in .htaccess change

 DirectoryIndex app.php

To

 DirectoryIndex app_dev.php

Then clear your cache : php app/console cache:clear

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

3 Comments

hum, i am stranger to Symbolic links, can you provide a simple example? And also, since i got two defferent symfont project in my public_html folder, doesn't symbolic link will break the ability to acces th esecond one?
First rename that portfolio folder (ex. to symfony). Then go to public_html and write: ln -s symfony/web/ portfolio Syntax is: ln -s /path/to/file /path/to/symlink
Worked, having somes troubles since i forgot to clear the cache, but i worked, thanks a lot
1

does it work with app.php? if so just replace app_dev.php with app.php

1 Comment

Actually : http://www.domain.com/~araymond/portfolio/web/app_dev.php/home does work, but i don"t want user to use this url, i want : http://www.domain.com/~araymond/portfolio/home as url, and i do not want to move to production environement

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.