Tower
Tower

Reputation: 102775

htaccess rewriting with url removal

I am trying to forward requests from /bar/baz to /web/index.php/bar/baz so that you do not have to use that "web" folder in the URL. So far I have /.htaccess:

RewriteEngine On
RewriteRule ^(.*)$ web/index.php [QSA,L]

The problem it has is that now the request to /controller/action/ causes an error:

No route found for "GET /web/controller/action"

The framework behind this does not matter, the point is that it should be controller/action without the additional "web" in the URL.

Upvotes: 1

Views: 107

Answers (1)

anubhava
anubhava

Reputation: 784938

Change your .htaccess code with this one:

Options +FollowSymLinks -MultiViews
RewriteEngine on

RewriteRule ^(?!web/index\.php|controller/)(.*)$ web/index.php/$1 [QSA,L,NC]

What this rule will do to internally redirect all the requests except that starting with /controller or /web/index.php to /web/index.php.

Upvotes: 1

Related Questions