0

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?

Jackson
  • 1,426
  • 3
  • 27
  • 60

4 Answers4

1

You can try this:

RewriteCond %{HTTP_HOST} !^www\.abc.\.com
RewriteRule ^(.*)$ http://www.abc.com/$1 [R=permanent,L]
0

I had simmilar issue but was cross domain one

Click Here

I got solved my issue via this.

You can even do via cname entries in dns as its in your similar two domains.

Community
  • 1
  • 1
Ashish
  • 1,856
  • 18
  • 30
0

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

Community
  • 1
  • 1
qsi
  • 683
  • 1
  • 7
  • 16
0

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

Krish Munot
  • 1,093
  • 2
  • 18
  • 29
VIVEK-MDU
  • 2,483
  • 3
  • 36
  • 63