Apache Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsSystem AdministrationApache Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 25th, 2001, 03:28 PM
sraynor sraynor is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2001
Posts: 3 sraynor User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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?

Reply With Quote
  #2  
Old December 26th, 2001, 12:24 AM
freebsd freebsd is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Posts: 5 freebsd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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?

Reply With Quote
  #3  
Old December 28th, 2001, 11:24 AM
sraynor sraynor is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2001
Posts: 3 sraynor User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally posted by freebsd
Don't quite understand you.

>> to see that address once they hit the hosted site
1) What hosted site? In what URL form? Hosted site is URL

2) What URL form do you want? URL

3) What URL form you don't want? URL

4) What should happen when a user goes to URL ? It should (and does) go to the subfolder "domain" under URL

5) What should happen when going to URL ? It should show URL

6) What should the user sees after typing URL in the browser's location bar?
It should show http:/www.domain.com as well as URL for any subfolders or files.

Sorry I wasn't so specific in my last post. Any help you can give is greatly appreciated!

Reply With Quote
  #4  
Old December 28th, 2001, 12:40 PM
freebsd freebsd is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Posts: 5 freebsd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
<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+).

Reply With Quote
  #5  
Old December 28th, 2001, 03:17 PM
sraynor sraynor is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2001
Posts: 3 sraynor User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
  #6  
Old December 28th, 2001, 03:59 PM
freebsd freebsd is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Posts: 5 freebsd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
>> 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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsSystem AdministrationApache Development > Renaming URLs


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway