I have a website: www.explainmortgage.com
On that website I have http://www.explainmortgage.com and http://www.explainmortgage.com/mortgage (among many other pages).
http://www.explainmortgage.com and http://www.explainmortgage.com/mortgage are identical so I want to 301 http://www.explainmortgage.com/mortgage to http://www.explainmortgage.com
I use this same codebase for multiple domains and most have a similar situation.
So I want to write one RewriteCond RewriteRule pair that will cover this situation on all my domains using this codebase.
So here is the rule (in psuedo code) that I want:
if ({HTTP_HOST}) contains ({REQUEST_URI} minus the leading /)
then 301 to http://{HTTP_HOST}
examples:
{HTTP_HOST} == 'www.explainmortgage.com'
{REQUEST_URI} == '/mortgage'
{HTTP_HOST} == 'www.explaincars.com'
{REQUEST_URI} == '/cars'
{HTTP_HOST} == 'www.explaineducation.com'
{REQUEST_URI} == '/education'
{HTTP_HOST} == 'www.explainelectronics.com'
{REQUEST_URI} == '/electronics'
So, if there are any regular expression gurus out there that would like to give me a hand, I would greatly appreciate it.