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.

Lukas Lukac
  • 7,766
  • 10
  • 65
  • 75

3 Answers3

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.

Wirone
  • 3,304
  • 1
  • 29
  • 48
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]
Lukas Lukac
  • 7,766
  • 10
  • 65
  • 75
-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>
Community
  • 1
  • 1
Nicolai Fröhlich
  • 51,330
  • 11
  • 126
  • 130
  • 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? – Lukas Lukac May 25 '13 at 10:30