I can't seem to get the regex in my htaccess redirect working:

RewriteRule [\./:_a-zA-Z0-9]*\/(web-browse(r|rs)-benchmarks)[a-zA-Z0-9-/\.:?=]*(|html) /web-browser-benchmarks-firefox-chrome/ [R=301,L]

Even .+(web-browser-benchmarks-firefox-chrome).+ won't work

I'm getting this error in chrome:

The www.domain.org page isn’t working

www.domain.org redirected you too many times. ERR_TOO_MANY_REDIRECTS


1 Answer 1


What seems to be happening, is your rule is being matched and then apache is sending a 301 redirect response telling the browser to generate a new request for


Chrome is generating this request - as instructed, but when your webserver see's this new request - your rule is matching that request too - again telling chrome to generate another request for /web-browser-benchmarks-firefox-chrome/ resulting in an infinite loop.
You can check with:

$ curl -I www.domain.org/web-browser-benchmarks-firefox-chrome/ 

You will probably see something like:

HTTP/1.1 301 
Server: apache
Location:  www.domain.org/web-browser-benchmarks-firefox-chrome/
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this is telling chrome/curl/etc to re-request the page it just requested
Date: Thu, 18 Feb 2016 08:56:02 GMT

You can try break the loop by with a conditional check - so assuming that


is the actual URL you want to serve, and your current rule uses [R=301,L] so Im assuming a 301 external redirect is what you want.

# this RewriteCond tells apache if this URL is requested, thats the URL we want
# so serve it instead of rewriting it.
RewriteCond "%{REQUEST_URI}" !^/web-browser-benchmarks-firefox-chrome/
RewriteRule [\./:_a-zA-Z0-9]*\/(web-browse(r|rs)-benchmarks)[a-zA-Z0-9-/\.:?=]*(|html) /web-browser-benchmarks-firefox-chrome/ [R=301,L]
  • Really well detailed answer here, looks like you even ran the checks too - nice one.
    – dan
    Commented Feb 18, 2016 at 9:07
  • Can I have more than 1 condition? Like if /web-browser-benchmarks-firefox-chrome/ or /web-browsers-benchmarks-firefox-chrome/ or /web-browser-benchmarks-firefox-chrome/index.html or 0/10/205/web-browser-benchmarks-firefox-chrome/ etc. is requestend THEN redirect any of these to to /web-browser-benchmarks-firefox-chrome/ Commented Feb 18, 2016 at 13:51
  • Currently my htaccess has got like 160+ lines of redirects. That's a mite much in my opinion. Commented Feb 18, 2016 at 15:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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