7

I'm looking for some help with my .htaccess file.

In short, I have a bunch of content up in the subdirectory www.myserver.com/forum/ (this directory is not my choice and cannot be changed), which includes both a forum (myserver.com/forum/forum) and a wiki (myserver.com/forum/wiki) and this is abviously not an ideal layout. I do not own myserver.com and there is content there that is not mine, though I have full access to the entire server.

I also have a domain name www.mydomain.com, which I want to redirect and mask such that if a user goes to mydomain.com/<something> they will be shown the content from myserver.com/forum/<something> while still being shown mydomain.com/<something> in the address bar.

One other thing I'd like to see, although it isn't vital, would by for a 404 generated by someone typing in mydomain.com/somethingThatDoesNotExist should redirect to mydomain.com/404.php instead of myserver.com's default 404.

I've tried a number of different approaches and searched extensively for the past day or so online - I'm sure that the answer is even here on SO somewhere, but all of the guides/examples I've tried have not worked and I feel like I'm going in circles.

Many thanks in advance.

EDIT: And I do know for sure that .htaceess is enabled.

DTR
  • 372
  • 6
  • 22

2 Answers2

2

if a user goes to mydomain.com/ they will be shown the content from myserver.com/forum/ while still being shown mydomain.com/ in the address bar.

First thing you need to understand that this is ONLY possible if mod_proxy is enabled on the Apache server of mydomain.com.

Once you've enabled mod_proxy, mod_rewrite and .htaccess through httpd.conf on mydomain.com, put this code in its .htaccess under DOCUMENT_ROOT directory:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On

RewriteRule ^(.*)$ http://myserver.com/$1 [L,P]

I will have to think little more about your 404 requirement, but if you get this working I am sure we can find a workaround for that as well.

anubhava
  • 761,203
  • 64
  • 569
  • 643
  • Thankyou for your reply. I was not able to modify htaccess on `mydomain.com` because it is registered with godaddy and they only appear to allow modification through their interface. However, I have managed to set everything up so that typing in `mydomain.com/` will forward to `myserver.com/forum/` correctly, so now I just need htaccess code to make `mydomain.com/` appear in the address bar. – DTR Jul 25 '13 at 11:40
  • Ok sure let me know it goes. Just keep in mind that if `P` flag isn't used (with mod_proxy enabled) then external redirection will occur and URL will indeed change in the browser. – anubhava Jul 25 '13 at 12:14
  • No it should not because it is not presenting a different content for human users and search engines. – anubhava Nov 16 '21 at 14:03
0

You could do some proxying with PHP or whatever other language they allow..
Take a look at file_get_contents behind a proxy?

Community
  • 1
  • 1
anapsix
  • 1,847
  • 20
  • 18