: Htaccess with regex not working properly! 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/
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 domain.org page isn’t working
domain.org redirected you too many times. ERR_TOO_MANY_REDIRECTS
More posts by @XinRu657
1 Comments
Sorted by latest first Latest Oldest Best
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
/web-browser-benchmarks-firefox-chrome/
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 domain.org/web-browser-benchmarks-firefox-chrome/
You will probably see something like:
HTTP/1.1 301
Server: apache
Location: 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
domain.org/web-browser-benchmarks-firefox-chrome/
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]
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.