"hiding a url"?

Discuss practical ways rearrange URLs using mod_rewrite.

"hiding a url"?

Postby public100 » Tue Oct 14, 2008 5:58 pm

Hello guys, lets say that i have a forum on (http://Asite.com/forum) but i want to print out another url, can that be done? - So it would look like the foum is located on another site? for example (http://Bsite.com/forum)

- the forum is still located on Asite.com/forum but i want the browser to show another location, if that possibly.
public100
 
Posts: 2
Joined: Sat Oct 11, 2008 5:33 pm

Postby richardk » Wed Oct 15, 2008 6:36 am

You would need to put the mod_rewrite in a .htaccess file on Bsite.com.
Are the sites on different servers? If they are, you will need mod_proxy on BSite as well as mod_rewrite.
If not, what are the document roots?
Mod_rewrite will not change the links that are outputted by the script.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby davidgelb » Sun Nov 02, 2008 9:17 pm

Hey - I am new to all the mod_rewrite stuff. My question is similar to the OP's question, so I am hoping there is someone who can help me...

I am using a php script that is tied to one of my domains. I would like to be able to get to that script via one of my other domains, but it must be accessed by the domain it is tied to.

The problem is, though, when someone enters the forwarded domain and it redirects, the actual URL is displayed in the address bar. I need the subdomain to display in the address bar, not the URL it was forwarded to.

Both sites are mine, so I have access to the HTAccess on both. Can someone tell me what the code would be to accomplish this?

for instance, I want someone to be able to enter 'http://show.mediasharz.com' which will redirect them to 'http://mysite.com/mediashare' but still display 'http://show.mediasharz.com' in the address bar.

Thank you in advance for your help!!

-David
davidgelb
 
Posts: 6
Joined: Sun Nov 02, 2008 9:04 pm

Postby richardk » Mon Nov 03, 2008 12:08 pm

Do both (sub) domains go to the same server? What are their document roots?

You will probably need mod_proxy, try the following in a .htaccess file in show.mediasharz.com
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^$ http://mysite.com/mediashare [P,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby richardk » Mon Nov 03, 2008 3:18 pm

Hi Richard,
Thank you for the help. I tried pointing my subdomain to a folder that contained the .htaccess you suggested. When entering the information exactly as you listed, I get an error 404 Not Found.

Am I doing something wrong? Should this subdomain still be redirected, or just pointed to the folder that contains the .htaccess?

The actual domain is http://example.com/mediashare and the subdomain that needs to point to it is http://sub.example.com


Thank you again.

-David

The .htaccess file is at sub.example.com/.htaccesss?
What happens if you replace P with R?
What happens if you replace ^$ with .*?
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby davidgelb » Tue Nov 04, 2008 6:04 pm

Hi Richard,
OK, changing the P to an R seemed to make the difference. Now when I enter http://sub.example.com, it forwards to http://example.com/mediashare

But, this setup does exactly the same thing as if I enabled forwarding on the subdomain - it still changes the address in the address bar.

So, I have an .htaccess that completes the forward, now I just need to figure out how to mask the URL. They are different domains, and one is registered with Hostmonster and the other with Godaddy, but the point to the same nameserver.

So, I guess the correct example would be: http://sub.example.com forwarding to http://maindomain.com/mediashare

Thank you for the help...I think I am getting closer......almost there.

Thanks,
David
davidgelb
 
Posts: 6
Joined: Sun Nov 02, 2008 9:04 pm

Postby richardk » Wed Nov 05, 2008 1:42 pm

Do they go to the same server? If they do, what are there document roots?
Do you have access to the server configuration?

If R works but P does not, it means you do not have mod_proxy. If they are on different servers, or you can't change the appropriate configuration you will not be able to do this.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby davidgelb » Wed Nov 05, 2008 5:24 pm

Hi Richard,
Yes, they point to the same server.

the sub domain points to the root: /public_html/subdomains/inseparable.gelbshare.com

the main domain points to the root: /public_html/thegelbs/mediashare

What server configuration do I need to change? If you can let me know, I will find out if I can...

Thanks!

-David
davidgelb
 
Posts: 6
Joined: Sun Nov 02, 2008 9:04 pm

Postby davidgelb » Wed Nov 05, 2008 11:06 pm

Hi Richard,
I asked Host Monster about mod_proxy or server config - I guess mod_proxy is not (they do not allow any type of proxy) but mod_rewrite is enabled. I do not have access to the httpd.conf file, however.

According to them, "the only way to accomplish url masking of any kind on our servers would be through mod_rewrite"

Does this help at all?

Thanks,
David
davidgelb
 
Posts: 6
Joined: Sun Nov 02, 2008 9:04 pm

Postby richardk » Thu Nov 06, 2008 8:36 am

If you don't have mod_proxy this can't be done with mod_rewrite.

You would have to change the sub domain's document root or and Alias might work. But you would need access to the httpd.conf file.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Next

Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 3 guests

cron