Vir
Vir

Reputation: 31

htaccess redirect

I am hosting an application made using zend framework. and I have .htaccess file on public folder to redirect all request to pass through index.php. It is working but I do not get request parameters in application. Why is this?

RewriteEngine on
Options +FollowSymlinks

RewriteBase /
RewriteRule !\.(js|ico|txt|gif|GIF|jpg|png|PNG|css|xml|JPG)$ 

index.php

Upvotes: 0

Views: 347

Answers (2)

Craig White
Craig White

Reputation: 14022

This will pass ALL requests excluding the file types listed to index.php

RewriteCond %{REQUEST_FILENAME} !\.(js|ico|txt|gif|GIF|jpg|png|PNG|css|xml|JPG)$
RewriteRule (.*)$ http://domain.com/index.php$1 [R=301,L]

Upvotes: 1

Phil
Phil

Reputation: 165059

That's not a very robust solution. What happens when a request is made to a file extension not included in your list?

The standard ZF 1.11 rules are much better

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

Upvotes: 1

Related Questions