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.
Related
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
This question already has answers here:
Redirect to other domain but keep typed domain
(2 answers)
Closed 6 years ago.
I have 2 vhosts: www.example1.com and www.example2.com
I have a page on www.example1.com/page.html
I want this page to be accessible in the other domain, meaning I want people to be able to get to www.example2.com/page.html and view that page that is physically on the other vhost. But the URL must display www.example2.com
I don't want to simply move the page physically to the other vhost, because it is a wordpress page and it would be a huge hassle.
Is this possible?
Yes it's possible.
I suggest reverse-proxy to do that. A software like NGinX does it very well, as well as apache of course (mod_proxy I recall).
Anyway, the downside of that approach is that your server (on www.example2.com) would request the page from example1 and send it through itself, and not directly from example1.
By the way - this technique is being used for load balancing as well.
Edit #1:
In nginx it's called ngx_http_upstream_module.
Edit #2:
grahaminn is correct yet my approach displays URL "correctly" - instead of one fixed URL which would make problems of, for example, bookmark a specific page.
Two options:
Use Apache ProxyPass: http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypass
Use Rewrite with [P] flag (requires mod_proxy installed)
RewriteRule /(.*)$ http://example2.com/$1 [P]
http://httpd.apache.org/docs/2.4/rewrite/flags.html
You can just serve a page from example2.com that uses javascript or an iframe to load the content from example1.com
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.
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.
I'm trying to find out how to edit my htaccess to push all requests for files in:
http://www.domain.com/images
to head off to:
http://cdn.domain.com/images
The reasoning being i'd like to parrelise http requests over a number of domains/subdomains to speed up page load. Is this possible through apache scripting, or will I have to go and edit all the links?
also... if there is a scripting solution, will it still give the end user the benefit of serving files from multiple domains?
Thanks,
Hugh
That would be more taxing than editing the links. The browser would have to make 2 HTTP requests for each image. Your main server would still have to serve the redirection. Then, the browser would make a second request to the actual image.
My judgment: edit your links.
Is there any reason you can't make cdn.domain.com be a cname for www.domain.com? If not, do this through bind, not apache.