|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Renaming URLs
I'm new to Apache and I'm having a problem with .htaccess files. I've finally figured out how to redirect an incoming URL for a NON hosted domain (ie. URL) to a hosted site's subfolder (ie. URL).
My problem is that I'd like the user who uses the URL URL to see that address once they hit the hosted site. For example, if I go to URL I end up going to the right location but I see the URL URL I'd like them to see URL and consequently, URL if they take a link to URL Is there any way to stop or modify this behavior on Apache v1.3? |
|
#2
|
|||
|
|||
|
Don't quite understand you.
>> to see that address once they hit the hosted site 1) What hosted site? In what URL form? 2) What URL form do you want? 3) What URL form you don't want? 4) What should happen when a user goes to http://www.domain.com/ ? 5) What should happen when going to http://www.hosted.com/domain/ ? 6) What should the user sees after typing http://www.domain.com/ in the browser's location bar? |
|
#3
|
|||
|
|||
|
Quote:
Sorry I wasn't so specific in my last post. Any help you can give is greatly appreciated! |
|
#4
|
|||
|
|||
|
<VirtualHost *>
ServerName www.hosted.com DocumentRoot /www/htdocs RewriteEngine on RewriteOptions inherit </VirtualHost> <VirtualHost *> ServerName www.domain.com DocumentRoot /www/htdocs/domain </VirtualHost> <VirtualHost *> ServerName www.foobar.com DocumentRoot /www/htdocs/foobar </VirtualHost> RewriteEngine on RewriteCond %{REQUEST_URI} ^/domain(.*)$ RewriteRule ^/icons/(.+) - [PT,L] RewriteRule ^domain(.+) http://www.domain.com$1 [R,L] RewriteCond %{REQUEST_URI} ^/foobar(.*)$ RewriteRule ^/icons/(.+) - [PT,L] RewriteRule ^foobar(.+) http://www.foobar.com$1 [R,L] BTW, why do you need to bother to do the redirection at all? If your user has his own domain, he should tell his friends to go to http://www.domain.com in the first place. If someone goes to http://www.hosted.com/domain/, just let them continue, why bother to do the redirection? It's the responsibility of domain.com's owner to tell people to go to www.domain.com. Doing this kind of external redirection is very inefficient when you have alot of vhosts (20+). |
|
#5
|
|||
|
|||
|
Dumb question, but...
Your reply looks great! Thanks for the detail!
One (possibly dumb) question: Do Virtual Host directives work in .htaccess files or only in httpd.conf? I don't have access to the httpd.conf with my account. Just curious. |
|
#6
|
|||
|
|||
|
>> Do Virtual Host directives work in .htaccess files
Only in httpd.conf or a file Include'd from httpd.conf. >> I don't have access to the httpd.conf with my account Then just add the following line to /www/htdocs/domain/.htaccess: RedirectMatch 301 ^/domain(.+) http://www.domain.com$1 Do not mkdir a directory named domain at /www/htdocs/domain/domain because there is a looping when requesting http://www.domain.com/domain while http://www.hosted.com/domain should redirect just fine. |
![]() |
| Viewing: Dev Shed Forums > System Administration > Apache Development > Renaming URLs |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|