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

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.

Related

How to point different domains to the same site

I've found myself in a situation where I have to use different domains for the same site.
It's a multilingual website that uses the path for the language so I have something like:
mysite.com/en
mysite.com/es
mysite.com/fr
mysite.com/ru
What I need is something like
mysite.com/en
misitio.es/es
monsite.fr/fr
bladimir.ru/ru
It's an Apache server. We enabled domain aliases and if I enter misitio.es the server redirects the web browser to mysite.com/es but showing misitio.es in the url.
What I would need is each domain to work on their own, not redirecting me, sharing all the content and source code. There should be no differences neither in files or in the database, and the htaccess should be configured to redirect each language (/es, /en, /fr, /ru) to its respective domain (*It's the last thing to do, we have not changed thw htaccess file yet).
I've found this guide for multisites in drupal, but it explains how to build a multisite from zero and my website is already in production, also, I'm not sure on how does it apply to my specific problem.
Is it possible to achieve what I need?
Any advice would be helpful.

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.

Using apache for dns blocking page and removing all jargon in URL

I have a little DNS Spoofing / Blocking system I setup for work. It simply uses a blacklist to spoof the dns records and simply points them to a BLOCK / DENY page.
If I go to the URL directly for instance http://www.redtube.com the system works as expected and displays my index.html and what it should
The problem arises if I go to http://www.redtube.com/video?/43 or anything other than the full domain I get a not found.
I need to to configure Apache so that it drops all the junk after the TLD and simply displays my page such as http://blocked.project.com
Another way to look at it would be to say redirect to index.html if the url entered is not known to the webserver.
Any help greatly appreciated.
Used an apache FallbackResource to achieve exactly what I was after. Had to make sure my image paths on the website were absolute but works a treat.
http://httpd.apache.org/docs/2.2/mod/mod_dir.html#fallbackresource

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

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.