I am trying to give each MOVIE there own url name, for example, www.helloworld.com/BATMAN. I have been using mod_rewrite to create such url. I have been using following htaccess code to achieve such result.

RewriteEngine ON
RewriteCond %(REQUEST_FILENAME) !-d
RewriteCond %(REQUEST_FILENAME) !-f
RewriteCond %(REQUEST_FILENAME) !-l

RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]

The mod_rewrite works perfectly. When A user enters randam movie name (name that does not exist in database), for example, www.helloworld.com/abcd, I have created a url redirect which is www.helloworld.com/oopsmovienotfound.php. This works fine too. But the problem I am having is this: When user click www.helloworld.com/login.php .The url keeps looping between login.php and oopsmovienotfound.php OR the url is forwarded to www.helloworld.com/oopsmovienotfound.php beacause database doesnot have "login.php" as a movie name. I thought this command

RewriteCond %(REQUEST_FILENAME) !-f

should have take care of this but its not. Please help. Thank you in advance.

6 Years
Discussion Span
Last Post by oksam

You should use curly brackets instead of parenthesis:

RewriteCond %{REQUEST_FILENAME} !-f

I have used curly brackets in the actual program. I must have missed type parenthesis on my question. My problem still exist with curly brackets. I would appreciate your suggestion.


I hope someone else can help you. Everything points to your code being correct, at least as far as I can tell.


@pzuurveen: RewriteCond %{REQUEST_FILENAME} !-f is fine according to the manual. This is preferred, so you do not have to exclude each file manually (as per example 1), and actually check if it is a real file (which example 2 does not do).

@oksam: Contact your provider. They should be able to tell you if this is perhaps unsupported in their setup.


add before RewriteRule

RewriteCond %{REQUEST_FILENAME} !login.php$

or to exclude all php

RewriteCond %{REQUEST_FILENAME} !^(.+)\.php$

found on http://www.datingking.net/ (NOT a dating site)

Hello pzuurveen,
Thank you for your answer, but I would get the same response even If i use both of the suggestion you posted. Would you plz help me with this situation. Thank you.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.