Jump to content

Recommended Posts

Hello All,

 

I am a Apache newbie, currently stuck up on URL masking setting  :(.

 

I have a URL called 'abc.maindomain.com', I would like to convert it to 'anotherdomain.com'... I know the setting to redirect the URL, but I am not able to mask the URL. Can anyone please help me to sought out my doubt regarding domain masking?.

 

 

Thanks in advance. :)

Ganesan.

 

  • 3 weeks later...

Hi,

 

I don't know if you have found a solution to your issue since its been about two weeks, but I wanted to reply back just in case. A 301 redirect setup on abc.maindomain.com would be best which can be done through an .htaccess file and also through IIS. 301 redirect is the most efficient and search engine friendly method for webpage redirection.

 

However, with linux hosting and using the .htaccess file you need to verify that mod_rewrite is enabled for Apache. If it is then you can use the following in your .htaccess file which should be placed into the webroot for abc.maindomain.com.

 

LINUX:

Create a .htaccess file with the below code, it will ensure that all your directories and pages of your old domain will get correctly redirected to your new domain.

The .htaccess file needs to be placed in the root directory of your old website (i.e the same directory where your index file is placed)

 

Options +FollowSymLinks

RewriteEngine on

RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]

 

You need to replace www.newdomain.com in the above code with your actual domain name.

 

IIS:

You will need to have remote access to use IIS Manager or have your hosting company do this for you.

 

In internet services manager, right click on the file or folder you wish to redirect

Select the radio titled "a redirection to a URL".

Enter the redirection page

Check "The exact url entered above" and the "A permanent redirection for this resource"

Click on 'Apply'

 

Redirects can also be performed using various programming languages like ASP, ASP.NET, PHP, and ColdFusion depending on your skill set and website coding. I'm including samples using a wide range of languages.

 

ASP

Response.Redirect("URL")

For example:

Response.Redirect(https://example.com) 


ColdFusion

<cflocation url="URL"> 

For example: 

<cflocation url="http://example.com">

* Absolute URLs and relative paths can be used as well.

PHP

The simplest way to do it is with PHP header function. The code you need is:

<?php
header("Location: http://www.example.com/"); /* Redirect browser */

/* Make sure that code below does not get executed when we redirect. */
exit;
?>

Perl

print "Location: http://www.example.com/\n\r\n\r";


JavaScript

<script language="JavaScript">
if( (document.location.href == "http://example.com/") || (document.location.href == "http://www.example.com/") )
window.location="http://new.domain.com";
</script>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.