Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have the following line in my .htaccess file, but it keeps redirecting me to a 404 error.

RewriteRule ^path1/([a-zA-Z0-9_-]+)/(.+)(/?)$ /file.php?variable1=$1&variable2=$2 [nc]

An example link would be..

I want to turn transfer that 2nd URL to variable2.

share|improve this question
up vote 1 down vote accepted

RewriteRule ^path1/([a-z0-9_-]+)/([^\?]+)$ /file.php?variable1=$1&variable2=$2 [NC]

Try the above rule and see. Your pattern is not matching that why you get the 404 error. By the way, I remove A-Z because NC will make it case-insensitive anyway.

share|improve this answer

I think that with only [NC] apache is looking for a file called 'file.php?variable1=$1&variable2=$2' (with variable subsitued) on the hard drive. You can try with [R,NC] or [PT,NC] (this one need mod_proxy)

share|improve this answer

Increase log level to Debug and see that mod_rewrite is doing.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.