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:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old March 29th, 2001, 02:15 AM
vera vera is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Posts: 4 vera User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to vera
Question

Can I use htaccess to redirect url such as :
URL to
URL ?

Reply With Quote
  #2  
Old March 29th, 2001, 10:35 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
# http://www.mydomain.com/.htaccess

RewriteEngine on
# If you have access to httpd.conf, enable this line (you can't use RewriteMap in .htaccess)
# If that's the case, of course, copy all lines here to within <Directory "/path/to/docroot">
# RewriteMap lc int:tolower
# Do not redirect if server_name doesn't contain .mydomain.com, use this to work with vhost
RewriteCond %{SERVER_NAME} !\.mydomain\.com$ [NC]
RewriteRule ^(.+) - [L]
# Do not redirect if server_name is already www.mydomain.com
# Say a request of http://www.mydomain.com/username/blah.html, then no redirection is needed
RewriteCond %{SERVER_NAME} ^www\.mydomain\.com$ [NC]
RewriteRule ^(.+) - [L]
# Else, if server_name is anything.mydomain.com
RewriteCond %{SERVER_NAME} ^[^.]+\.mydomain\.com$ [NC]
# Take the server_name env to the next rule
RewriteRule ^(.+) %{SERVER_NAME}=$1 [C]
# If RewriteMap above is enabled, comment out the following line
# What this line does is to map http://USERNAME.mydomain.com/ to http://www.mydomain.com/username/
# That's converting Uppercase Username to lowercase
# RewriteRule ^(.*)=(.*) ${lc:$1}$2 [C]
# ^([^.+) is the username
# (.*) is the / or anything requested, this is also called request_uri
# $1 is the value of username
# $2 is the value of request_uri including the slash /
RewriteRule ^([^.]+)\.mydomain\.com(.*) http://www.mydomain.com/$1$2 [R,L]

Once again, any codes I post here is untested (just wrote this up from scratch), so please followup this thread whether it works for you or not.

Reply With Quote
  #3  
Old March 29th, 2001, 11:02 PM
vera vera is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Posts: 4 vera User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to vera
Dear freebsd,

I added the above lines to my httpds.conf, and now it looks like this : ( offcourse i changed the mydomain with my domain name),
<Directory "/usr/local/plesk/apache/vhosts">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
RewriteEngine on
RewriteCond %{SERVER_NAME} !\.mydomain\.com$ [NC]
RewriteRule ^(.+) - [L]
RewriteCond %{SERVER_NAME} ^www\.mydomain\.com$ [NC]
RewriteRule ^(.+) - [L]
RewriteCond %{SERVER_NAME} ^[^.]+\.mydomain\.com$ [NC]
RewriteRule ^(.+) %{SERVER_NAME}=$1 [C]
RewriteRule ^([^.]+)\.mydomain\.com(.*) URL$1$2 [R,L]
</Directory>
but i doesn't work as i expected.
Could you tell me what possibly be the problem?
Thank You.

Vera.

Reply With Quote
  #4  
Old March 30th, 2001, 11:15 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
1) As I said, put those with <Directory "/path/to/docroot">. Are you sure /usr/local/plesk/apache/vhosts is your docroot? Check your httpd.conf and find the line DocumentRoot blahblahblah. The blahblahblah is the path of your docroot.
2) Say your docroot (DocumentRoot is /usr/local/plesk/apache, there must not be a subdir at
/usr/local/plesk/apache/no_subdir_here/username

Since you haven't provided any details of the problem, I suggest you to try to solve the problem yourself by adding:

RewriteEngine on
RewriteLog "/var/log/rewrite.log" # add this line, create this file manually before restarting apache
RewriteLogLevel 9 # add this line
RewriteCond %{SERVER_NAME} !\.mydomain\.com$ [NC]
..
..

Reply With Quote
Reply

Viewing: Dev Shed ForumsSystem AdministrationApache Development > htaccess to redirect url


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 3 hosted by Hostway