?
Solved

.htaccess 301 redirect subfolder to another domain?

Posted on 2012-08-11
4
Medium Priority
?
784 Views
Last Modified: 2012-08-12
How can I do a .htaccess 301 redirect to redirect a subfolder to another domain?

Thanks
0
Comment
Question by:DantechIT
  • 2
  • 2
4 Comments
 
LVL 2

Accepted Solution

by:
loginzhang earned 2000 total points
ID: 38285098
here are some ways to do it.

#1 put a .htaccess in a subfolder and it content will be:

RewriteEngine on
RewriteRule ^/?$ "http\:\/\/www\.domainname\.com" [R=301,L]

in this way, the URL in the browser will change to www.domainname.com

#2 put a .php file in the subfolder and it name will be index.php, content will be:

<?php
$url="http://www.domainname.com";
header("Location: $url");
?>

in this way, the URL in the browser will change to www.domainname.com

#3 if you do not want change the URL in browser, you need use iframe or reverse proxy
0
 

Author Comment

by:DantechIT
ID: 38285732
Thank you. When I do that it redirects but ads the original subfolder to the end, see example:

if I put an .htaccess file in the folder www.mydomain.com/EE

RewriteEngine on
RewriteRule ^/?$ "http\:\/\/www\.domainname\.com\/folder\/" [R=301,L]

When I go to www.mydomain.com/EE it redirects me to www.domainname.com/folderEE
0
 
LVL 2

Expert Comment

by:loginzhang
ID: 38286557
RewriteEngine on
RewriteRule ^/?$ "http\:\/\/www\.domainname\.com\/folder\/" [R=301,L]

Open in new window


the URL in second line is the target.
If you just want redirects to www.domainname.com, you do not need add \/folder\/
0
 

Author Comment

by:DantechIT
ID: 38286633
Disregard, I had a cache issue.

Thank you for your help, it worked.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When the s#!t hits the fan, you don’t have time to look up who’s on call, draft emails, call collaborators, or send text messages. An instant chat window is definitely the way to go, especially one like HipChat. HipChat is a true business app. An…
How do you create a user-centered user experience on your website? And what are some things you should consider in the process?
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
Suggested Courses

609 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