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.


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.


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)


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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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