Way to get around subdomain vs subfolder in terms of SEO? - apache

I have a main domain, www.example.com, that has ranking and 'trust' in Google. I'm creating a blog, but, for various reasons, I HAVE to host it on a subdomain, sub.example.com.
I know that when a subdomain is created, Google treats it as a new site and will eventually see it as part of the main domain (after a very long while). What I'm looking for here is a way around this or a way to expedite this process. Is it possible?
Possible solutions:
Using modrewrite to rewrite sub.example.com to www.example.com/sub. I'm not too familiar with rewriting so I'm not sure if it works like this. If it does, would this be a solution to this issue?
Creating a subfolder on www.example.com like www.example.com/sub, and, in that subfolder, include a redirect to sub.example.com. That way when Google crawls www.example.com/sub it will find the link to sub.example.com. Will it then see the subdomain as part of the real domain?
Are these viable solutions? Is there anything else that could be done?
Thanks.

mod_rewrite won't let you convert the subdomain to a folder, but mod_proxy will.
You'll want something like this in your apache config file in the virtual host section for www.example.com:
ProxyRequests Off
ProxyPass /sub http://sub.example.com/
ProxyPassReverse /sub http://sub.example.com/
Then your blog is running in both places. You'd probably want to put canonical tags on it so that Googlebot knows which is the preferred one.

Google treats subdomains and subdirectories the same. They do not see subdomains as new websites.

Related

Redirect but keep the ENTIRE URL

I've got a problem with my domain structure (the title describes it very well).
What I've tested so far:
I googled a lot and found many threads about "Redirect from domainA to domainB without changing the URL" (often with .htaccess). They talk about simple redirect rules and the proxy flag and so on. So I tried a lot of them but everytime they just keep the path after domainB and redirect then to domainA.
What I want (detailed): I've got two domains with different IPs and when someone hit "http://www.domainA.com" it should just SHOW the content from "http://www.domainB.com" but also SHOW the URL from domainA. So when one is browsing trough my website like "http://www.domainA.com/link1" it also should show the content from "http://www.domainB.com/link1", but show the URL with "domainA".
Of course I could show you some htaccess code I used, but I start to think that htaccess is not the solution.
So I ask you guys: Is this possible with htaccess? What other solutions are possible?
You can use Mod_proxy module.
Put below in your virtualhost for www.domainA.com
ProxyPass / http://www.domainB.com
ProxyPassReverse / http://www.domainB.com
This can also be achieved with help of Mod_proxy_ajp & Mod_JK module.

Htaccess subdomain exceptions to rewriterule

I host in siteground, on a multiple domain account,
Main domain is pointed to public_html, so it's a bit dangerous for the rest of sites in the account to use it (unwanted deletes, hacks, and so...)
I successfully followed this guide (http://www.ianholden.com/how-to/hide-joomla-subdirectory/) to point mydomain.com to midomain.com/mydomain folder (joomla install)
But now I have a problem with existing subdomains for sites still without their own domain names, that give a 500 error when visited...
What could I use to leep my current rewrite rule mydomain.com -> mydomain.com/mydomain and make exceptions for subdomains as whatever.mydomain.com?
Thanks
The problem is that the rule that you have added to your .htaccess file will affect all other sites on your hosting account, since the .htaccess file is at the same level of all those sub-directories.
If you have too many sites hosted this way, then I suggest you go with a VPS, and then create an account for each and every domain that you have. This will ensure that your websites run smoothly and in silos.
Whatever you do to make Joomla work properly under a subdomain, will create problems for you on the long run.

Redirect domain.com to www.domain.com?

Got a bit of a problem - my current DNS and apache setup allows my site to be accessed from both http://domain.com/ and http://www.domain.com/. However, the CMS application currently in use requires the URL be http://www.domain.com/, or problems arise.
For the sake of argument, consider modifying the CMS as out of the question. How would I force http://domain.com/ to redirect to http://www.domain.com/ on a DNS/Apache level? I don't have much experience with DNS acrobatics, and .htaccess is pretty multifaceted so it's hard to pin down a proper solution. Therefore, I'm relying on your opinions and expertise. Thanks in advance!

htaccess - rewrites/redirects for addon domains?

I am planning to create some addon domains through cPanel, I'm aware that their content can be accessed by visiting addondomain.maindomain.com and maindomain.com/addondomain - this could lead to duplicate content with search engines, amongst other things, so I would like to prevent this if possible.
After some research it seems the best (probably only) option would be to use .htaccess and rewrites so that the addon domain can only be accessed at www.addondomain.com - what is the best way to go about doing this and can I have the .htaccess file within the maindomain.com directory or will I need it for each addon domain I create?
Any help would be much appreciated, thank you :)
RewriteRule ^addonedomain/(.*)$ http://addondomain.maindomain.com/$1
this code will redirect user from maindomain.com/addonedomain directory to addonedomain.maindomain.com !
it's better to put this code in .htaccess file in root of add-on domain!

How to remove a directory from URL with .htaccess..?

Ok, I've read so many examples on so many sites, it gets really hard to understand what's going on when it seems there are dozens of way to do anything with .htaccess.
Anyway, here's my setup: I have 2 domain names example1.com and example2.com
example1.com is an add-on domain, so its root is in the subfolder /example1.com/ on my server. When I type www.example1.com, that's what I see: http://www.example1.com/ That's perfectly fine.
example2.com is a parked domain, it points to the same folder /example1.com/ . When I type www.example2.com, that's what I see: http://www.example2.com/example1.com/ I would like NOT to see the subfolder, I would like to see http://www.example2.com/ but have the same content served.
There must be a way to do this with htaccess. I Hope someone can help.
Thanks.
You could use an iframe (ie: A box that syndicates another web-page) and skip any hassle with htaccess. The results are indistinguishable.