Krish Gowda
Krish Gowda

Reputation: 193

rewrite rule prevents image file requests

my .htaccess file is as follows.

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^write$ /write.php [L]
RewriteRule ^write/([^/]*)$ /write.php?bid=$1 [L]
RewriteRule (.*)/(.*)/(.*) blog.php?author=$1&title=$2&date=$3

The problem is request for an image file is redirected to blog.php file. For example request for http://domainname.com/images/10005/Brooklyn-Museum.jpg is redirected to blog.php. how to correct this to access existing static resources properly?

Upvotes: 1

Views: 47

Answers (1)

anubhava
anubhava

Reputation: 784998

Have your rules like this:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

RewriteRule ^write/?$ /write.php [L,QSA]

RewriteRule ^write/([^/]+)/?$ /write.php?bid=$1 [L,QSA]

RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ /blog.php?author=$1&title=$2&date=$3 [L,QSA]

Upvotes: 1

Related Questions