Connecting Tech Pros Worldwide Forums | Help | Site Map

htaccess redirect every request to root? catch all..

hsriat's Avatar
Expert
 
Join Date: Jan 2008
Location: Bath, UK
Posts: 1,609
#1: Sep 11 '09
Hi,

I have been trying to redirect request to any of the pages on an "under-construction" website to root.

e.g. redirect www.example.com/randomxyz to www.example.com

I wrote this code, but didn't seem to work. Any suggestions?
Expand|Select|Wrap|Line Numbers
  1. RedirectMatch ^([.]+)$ http://www.example.com

Atli's Avatar
Moderator
 
Join Date: Nov 2006
Location: Iceland
Posts: 3,754
#2: Sep 11 '09

re: htaccess redirect every request to root? catch all..


Hey.

I'm not all that used to using RedirectMatch, but that kind of looks like an indefinite loop to me.
It redirects everything to example.com, even example.com.

Try something like
Expand|Select|Wrap|Line Numbers
  1. RedirectMatch ^http://www.example.com.+$ http://www.example.com
P.S.
I've moved this over to the Apache forums.
hsriat's Avatar
Expert
 
Join Date: Jan 2008
Location: Bath, UK
Posts: 1,609
#3: Sep 15 '09

re: htaccess redirect every request to root? catch all..


No success man... still the infinite loop.


Anyway... don't worry... I'm not implementing it now.

Thank you :)
Plater's Avatar
Moderator
 
Join Date: Apr 2007
Location: New England
Posts: 7,161
#4: Sep 15 '09

re: htaccess redirect every request to root? catch all..


I think you may need the extra / in there at the end of the .com in the match side. Maybe that will help?
Also possible the http://-etc does not appear i nthe match behavior?
Expand|Select|Wrap|Line Numbers
  1. RedirectMatch ^http://www.example.com/.+$ http://www.example.com
  2.  
Anything good here?
http://www.webweaver.nu/html-tips/web-redirection.shtml
Reply