Reputation: 1524
I have one domain abc.ca is already running & google crawled that url.
Now i'm going for abc.com
so how can i manage all URL's of abc.ca -> abc.com
using htacees. Site is built in PHP Joomla.
abc.ca/def.html -> abc.com/def.html
there are thousands of pages. I can't write individual 301 redirection in htaccess.
We can do this in PHP
$uri = "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
$newUrl = str_replace(".ca", ".com", $uri);
header("Location: " . $newUrl);
It's better to do on PHP site or htaccess site?
Upvotes: 0
Views: 1230
Reputation: 2559
try this
<FilesMatch "\.(tpl|ini|log)">
Order deny,allow
Deny from all
</FilesMatch>
RewriteBase /
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteRule ^download/(.*) /index.php?route=error/not_found [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
Here you can modify RewriteBase /
into your domain name.
For sub domain you can give like this RewriteBase /subfolder
Upvotes: 0
Reputation: 683
I didn't test it but it should be like this:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^abc.ca$ [OR]
RewriteCond %{HTTP_HOST} ^www.abc.ca$
RewriteRule (.*)$ http://www.abc.com/$1 [R=301,L]
Redirect 301 /old/old.htm http://www.domain.com/new.htm
else you might want to take a look at this question
Upvotes: 0
Reputation: 1952
I had simmilar issue but was cross domain one
I got solved my issue via this.
You can even do via cname entries in dns as its in your similar two domains.
Upvotes: 0
Reputation:
You can try this:
RewriteCond %{HTTP_HOST} !^www\.abc.\.com
RewriteRule ^(.*)$ http://www.abc.com/$1 [R=permanent,L]
Upvotes: 1