2

Is it possible to have a 301 redirect without moving files?

I have a site currently at a .ca domain.

Now I want the primary domain to be .org. I would like to do this in a way that is search engine friendly. I have been told I can do this with 301 redirects.

Is it necessary for me to move my files over to another server / folder or can I just write the 301 redirects so that the URL changes to the preferred .org domain?

2 Answers 2

1

A 301 (moved permanently) redirect is an instruction to the user that the file that is being requested has moved to a different location. The result is that the browser requests the file located at the new location.

If you currently have a site at example.ca but wish to use example.org instead (without moving any files) then you will first need to setup example.org as a parked domain on your hosting account (providing your webhost supports this). Your site would then be accessible by both domains.

To solve the duplicate content issue and set example.org as the primary domain for your users then set up a 301 redirect from example.ca to example.org in .htaccess:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.ca [NC]
RewriteRule (.*) http://example.org/$1 [R=301,L]

If the requested HTTP_HOST is "example.ca" then 301 redirect the request to "example.org".

1

Yes! It is possible to have a 301(Permanent redirect) without moving the files to the new location.

301 redirection can be achieved using your hosting control panel(for example cPanel) or using the .htaccess file.

You can use the code provided by @w3d in order to achieve this.

You can use the following code in the .htaccess file if you wish to have a stealth redirecton(URL Masking).

RewriteEngine on
RewriteCond %{HTTP_HOST} ^testdomains.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.testdomains.com$
RewriteRule ^(.*)$ "http\:\/\/www\.example\.com\/Test Domains$1" [P,L]

URL masking will ensure that your visitors see the source URL and not the destination URL.

1
  • 1
    Just to note, the second argument in the RewriteCond directive is a regular expression, so the periods should be escaped: ^testdomains\.com$. And conversely the second argument in the RewriteRule directive is not a regular expression, so the slashes, colons and periods should not be escaped.
    – MrWhite
    May 12, 2013 at 13:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.