Require domain alias to show in browser address bar
.htaccess files are extremely useful in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about domains, htaccess, apache, redirects, .htaccess common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your .htaccess file running smoothly.Problem :Similar to question posted here (but not related to sub directories):
.htaccess redirect of domain name alias to main domain but must show up as the alias domain
I am trying to direct traffic from an alias domain I have to my site that is on the same server, while also keeping the alias domain in the browser address bar.
This is my original htaccess content which correctly redirects the user, but xyz.com appears in the browser which I do not want.
rewritecond %HTTP_HOST ^(www.)?abc.com$ [NC]
rewriterule ^ http://xyz.com/?foo [R=301,QSA,L]
This is my attempt to not only bring abc.com visitors to xyz.com but also have abc.com appear in the browser. This doesn't even load the site. Any ideas on a fix?
rewritecond %HTTP_HOST ^(www.)?abc.com$
RewriteRule ^$ /index.html [L]
I'm gonna assume each domain you're inquiring about are assigned separate document root folders on the same server.
I'll assume the document root for abc.com is in the /abc/public_html folder, and document root for xyz.com is in the /xyz/public_html folder.
Because you don't want xyz.com to show up and you want data from it, you have a couple of options.
If you use a linux server, you can turn all files (except .htaccess) in /abc/public_html folder as symbolic links pointing to the files in /xyz/public_html folder.
An easier way is to copy the files over so /abc/public_html has exactly the same contents as /xyz/public_html, but this option requires more disk space.
Update .htaccess so any requests to xyz.com are forwarded to abc.com so that there won't be duplicate content issues.
Any time you redirect you are telling the browser to change the URL as it appears to the user. There are three approaches you could take for this problem.
- Serve both domains out of the same folder. This will mean that both domains have the same (duplicate) content. This solution works when both domains are served from the same server. You just need to set the virtual hosts to have the same
DocumentRootdirectory. - mod_proxy in reverse proxy mode allows your domain to re-serve the contents from another domain. When it gets a page request, it fetches it from the other domain and serves it again. This will work even when the two domains are served on different servers. It will also create duplicate content and is slower than serving the content directly.
Framed redirects. A framed redirect uses client side HTML frames to show the content of another domain.
<frameset rows="100%,*" border="0">
<frame src="http://othersite.example.com/" noresize frameborder="0">
</frameset>This solution is not great because:
- It doesn't work well for SEO -- Google still directs users to the other site
- The URL doesn't change as users navigate the site. This make is hard for users to bookmark or share content.
Comments
Post a Comment