I have a website on cpanel (WHM access also) and i have 3 domain names. My main one, and 2 others. I've parked the two other domains via my cpanel onto the main domain account. I've changed the htaccess to include the following and redirect from the other domains to the main one: ErrorDocument 404 /index.html RewriteCond %{HTTP_HOST} ^domain1.co$ [OR] RewriteCond %{HTTP_HOST} ^www.domain1.co$ RewriteRule ^(.*)$ http://www.maindomain.co.uk/$1 [R=301,L] RewriteCond %{HTTP_HOST} ^maindomain.co.uk$ [NC] RewriteRule ^(.*)$ http://www.maindomain.co.uk/$1 [R=301,L] RewriteCond %{HTTP_HOST} ^domain2.net$ [OR] RewriteCond %{HTTP_HOST} ^www.domain2.net$ RewriteRule ^(.*)$ http://www.maindomain.co.uk/$1 [R=301,L] Code (markup): All seems fine when i do this and domain1/whatever.html and domain2/whatever.html redirect to the corresponding maindomain/whatever.html. All good so far! The problem is, whenever i type a URL in that ends in index.htmt or product_info.html it fails to redirect as it should... this is the offending code in my htaccess i think, but i don't have a clue how to read it so i need you help to make it work only with maindomain.co.uk: # reformats for product_info.html pages RewriteRule ^m(.*)/(.*)/p(.*)/(.*)/product_info\.html$ product_info.php?manufacturers_id=$1&products_id=$3 [QSA,L] RewriteRule ^p(.*)/(.*)/product_info\.html$ product_info.php?products_id=$1 [QSA,L] RewriteRule ^(.*)/c(.*)/p(.*)/(.*)/product_info\.html$ product_info.php?cPath=$2&products_id=$3 [QSA,L] # reformat for index.html pages RewriteRule ^m(.*)/(.*)/p(.*)/(.*)/index\.html$ index.php?manufacturers_id=$1&products_id=$3 [QSA,L] RewriteRule ^m(.*)/(.*)/index\.html$ index.php?manufacturers_id=$1 [QSA,L] RewriteRule ^(.*)/c(.*)/m(.*)/(.*)/p(.*)/(.*)/index\.html$ index.php?cPath=$2&products_id=$5 [QSA,L] RewriteRule ^(.*)/c(.*)/p(.*)/(.*)/index\.html$ index.php?cPath=$2&products_id=$3 [QSA,L] RewriteRule ^(.*)/c(.*)/index\.html$ index.php?cPath=$2 [QSA,L] Code (markup): I'm sure its quite easy but i have little knowledge of regular expressions...i should really learn. Thanks in advance to anyone who solves my puzzle
ErrorDocument 404 /index.html RewriteCond %{HTTP_HOST} ^domain1.co$ [OR] RewriteCond %{HTTP_HOST} ^www.domain1.co$ RewriteRule ^(.*)$ http://www.maindomain.co.uk/$1 [R=301,L] RewriteCond %{HTTP_HOST} ^maindomain.co.uk$ [NC] RewriteRule ^(.*)$ http://www.maindomain.co.uk/$1 [R=301,L] RewriteCond %{HTTP_HOST} ^domain2.net$ [OR] RewriteCond %{HTTP_HOST} ^www.domain2.net$ RewriteRule ^(.*)$ http://www.maindomain.co.uk/$1 [R=301,L] Code (markup): Can be shortened to just: ErrorDocument 404 /index.html RewriteEngine On RewriteCond % !^www\.maindomain\.co\.uk [NC] RewriteRule (.*) http://www.maindomain.co.uk/$1 [R=301,L] Code (markup): As for the 2nd block more information on what you're actually trying to achieve would be good, the source urls and what you want them to invoke and so on. Was this working before you added the redirects for the parked domains?
Simply use a 301 Redirect right from the Cpanel Its that Easy!! You can Get the Redirection Option right next to the Addon Domain Option!! ~ExP~
It's really not...that extra bit of code stops anything with 'index.html' at the end, from redirecting properly. It's a bought script for an ecommerce site, just to clarify: i go to domain1.co/blah.html it redirects to maindomain.co.uk/blah.html - all good i go to domain2.net/blah2.html it redirects to maindomain.co.uk/blah2.html - all good again if i go to domain1.co/index.html it fails to redirect to maindomain.co.uk/index.html and stays on domain1.co/index.html which should be redirecting! if i go to domain2.net/index.html it fails to redirect to maindomain.co.uk/index.html and stays on domain2.net/index.html which should be redirecting! its the same with anything that ends 'index.html' i.e. domain2.net/product/category/index.html ont redirect. If i remove the second bit of code from htaccess they redirect fine again, but the main site doesnt work properly. So all i need i think, is to change this bit of code: # reformats for product_info.html pages RewriteRule ^m(.*)/(.*)/p(.*)/(.*)/product_info\.html$ product_info.php?manufacturers_id=$1&products_id=$3 [QSA,L] RewriteRule ^p(.*)/(.*)/product_info\.html$ product_info.php?products_id=$1 [QSA,L] RewriteRule ^(.*)/c(.*)/p(.*)/(.*)/product_info\.html$ product_info.php?cPath=$2&products_id=$3 [QSA,L] # reformat for index.html pages RewriteRule ^m(.*)/(.*)/p(.*)/(.*)/index\.html$ index.php?manufacturers_id=$1&products_id=$3 [QSA,L] RewriteRule ^m(.*)/(.*)/index\.html$ index.php?manufacturers_id=$1 [QSA,L] RewriteRule ^(.*)/c(.*)/m(.*)/(.*)/p(.*)/(.*)/index\.html$ index.php?cPath=$2&products_id=$5 [QSA,L] RewriteRule ^(.*)/c(.*)/p(.*)/(.*)/index\.html$ index.php?cPath=$2&products_id=$3 [QSA,L] RewriteRule ^(.*)/c(.*)/index\.html$ index.php?cPath=$2 [QSA,L] Code (markup): ...so it works only with maindomain.co.uk and not work with the other parked domains. If you need more info let me know...i think it should be quite straight forward though?
That block is independent of the domain name, can you post the whole of your .htaccess file as I'm assuming there's something conflicting in it.