troubleshooting Question

rewrite in htaccess only following the last rewrite rule, ignoring the others

Avatar of Neil Thompson
Neil ThompsonFlag for United Kingdom of Great Britain and Northern Ireland asked on
PHPApache Web Server* URL Rewrite Rules
7 Comments1 Solution148 ViewsLast Modified:
hi all

I have an issue with my rewrite in a .htaccess file that I'm unsure how to fix.

I want to be able to pass parameters as a query variable when someone uses the url for example www.mysite.com/user/reset/asdfg12345 to be re-written as www.mysite.com/user/reset/?rp=asdfg12345

My code below works but only for the very last rule so in this case RewriteRule ^user/verify/([^/\.]+)/?$      user/verify/?uvc=$1 [L] , the rule or rules above it never work, If I change the order again the last one only ever works.

Sure it's a simple error but something I'm not sure about.

Thanks in advance all, Neil


RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_REFERER} !^$  

# allows reset URL like /user/reset/5d34f4e59c155566913f782a2e2557dc,234j5hj23k452hk
RewriteRule ^user/reset/([^/\.]+)/?$	user/reset/?rp=$1 [L] 

# allows verification URL like /user/verify/5d34f4e59c155566913f782a2e2557dc
RewriteRule ^user/verify/([^/\.]+)/?$	user/verify/?uvc=$1 [L]

ErrorDocument 404 404.php 

############################################
## never rewrite for existing files, directories and links
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l

## rewrite everything else to index.php
RewriteRule .* index.php [L]
ASKER CERTIFIED SOLUTION
Dr. KlahnPrincipal Software Engineer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros