0

I am trying to hide the app.php from url

I have:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ app.php [QSA,L]

Which works okay.. but when user visit

domain.com/app.php/Home/

than the url is still

domain.com/app.php/Home/

and i want have only

domain.com/Home

How to solve it?

I tried:

#RewriteCond %{THE_REQUEST} ^.*/app.php
#RewriteRule ^(.*)app.php/(.*)?$ /$2 [R=301,L]

Which work as i need but when i do some action dynamic jquery ajax action i get error 405.

3
  • you have uncommented ( removed the # ) the "#RewriteCond %{THE_REQUEST} ^.*/app.php" directive before you actually tried it , did you? :) Commented May 24, 2013 at 13:20
  • nice joke :) Yes i did :D As i said: Which work as i need ... but this do a 405 error problem while using ajax etc. Commented May 24, 2013 at 13:23
  • please try out my answer :) Commented May 24, 2013 at 14:47

3 Answers 3

2

Seems like you don't have mod_rewrite enabled. You have to do on your machine:

  • sudo a2enmod rewrite (or enable module in other way if you don't have a2enmod)
  • service apache2 restart or /etc/init.d/apache2 restart

Next, you have to set AllowOverride All in your vhost config to be sure URLs will be properly catched by Symfony's web/.htaccess.


Additional info: in Symfony's web/.htaccess:

<IfModule !mod_rewrite.c> <IfModule mod_alias.c> # When mod_rewrite is not available, we instruct a temporary redirect of # the start page to the front controller explicitly so that the website # and the generated links can still be used. RedirectMatch 302 ^/$ /app.php/ # RedirectTemp cannot be used instead </IfModule> </IfModule>

If mod_rewrite is not enabled, apache uses mod_alias to pass all requests through app.php. So if you enter root URL of your domain and you're redirected to app.php it's probably because of mod_rewrite.

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

Comments

0

I wrote something like this but i am not sure if its good solution?

RewriteCond %{THE_REQUEST} ^.*/app.php 
RewriteCond %{REQUEST_METHOD} !=POST
RewriteRule ^(.*)app.php/(.*)?$ /$2 [R=301,L]

Comments

-1

The solution to your problem is described here.

<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]
</IfModule>

1 Comment

Hm.. i have read it but i am not sure how this can help me? Its not seems to work ... please check my answer what you say on it?

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.