Solved

301 redirect htaccess subdomain pages to main page

Posted on 2010-11-08
2
428 Views
Last Modified: 2012-05-10
Hi,

I'd like to 301 redirect several subdomain pages to the main page (http://omusicstudios.com)

Here is the part of my htaccess:

Options +FollowSymLinks
RewriteEngine On

RewriteRule ^teachers/don.html$ /teachers/don.php
RewriteRule ^teachers/doug.html$ /teachers/doug.php
RewriteRule ^teachers/megan.html$ /teachers/megan.php
RewriteRule ^university.html$ /university.php
RewriteRule ^university-contact.html$ /university-contact.php

Open in new window

0
Comment
Question by:Victor Kimura
2 Comments
 
LVL 10

Assisted Solution

by:honestman31
honestman31 earned 250 total points
ID: 34088273
in the each sub domain you want to redirect  go to folder www.domain.com/sub1/ 

and insert the following codes in htaccess  file  

redirect 301 / http://domain.com/.

copy that htaccess to every folder of the sub-domain you want to redirect
i.e  www.domain.com/sub2/
and www.domain.com/sub3/ 

and so on
0
 
LVL 26

Accepted Solution

by:
arober11 earned 250 total points
ID: 34088312
If you just want a 301 rather than a 302 redirect simply add a [R=301] to the end of you rule. e.g.

RewriteRule ^teachers/don.html$ /teachers/don.php [R=301]

If you what to control the hostname seen in the browser just add it to the destination e.g.

RewriteRule ^teachers/don.html$ http://omusicstudios.com/teachers/don.php 


If you have some other requirement then please set out what you are trying to achieve in the format detailed in the "How to define your own Redirects or Rewrites: " section of this article: http://www.experts-exchange.com/A_4043.html then post it back here.
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
What You Need to Know when Searching for a Webhost Provider
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question