Forum Moderators: phranque
i have attempted to alter the script below with no luck
############################
rewriteEngine On
# Rewrite <subdomain>.example.com/<path> to example.com/<subdomain>/<path>
#
# Skip rewrite if no hostname or if subdomain is www
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST}!^www\. [NC]
# Extract (required) subdomain (%1), and first path element (%3), discard port number if present (%2)
RewriteCond %{HTTP_HOST}<>%{REQUEST_URI} ^([^.]+)\.example\.com(:80)?<>/([^/]*) [NC]
# Rewrite only when subdomain not equal to first path element (prevents mod_rewrite recursion)
RewriteCond %1<>%3!^(.*)<>\1$ [NC]
# Rewrite to /subdomain/path
RewriteRule ^(.*) /%1/$1 [L]
thanks
[edited by: jdMorgan at 4:43 pm (utc) on June 17, 2005]
[edit reason] example.com [/edit]
The code above will only work if your server's OS support POSIX 1003.2 regular expressions. The simpler techniques discussed in this thread [webmasterworld.com] can be used if this is not the case.
Jim
[Sat Jun 18 11:19:19 2005] [error] File does not exist: /home//fst/var/www/html/timmy
from typing in : http://timmy.example.com
with the following code:
# Rewrite <subdomain>.example.com/<path> to example.com/<subdomain>/<path>
# the '' must be removed for it to work
# Skip rewrite if no hostname or if subdomain is www
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\. [NC]
# Extract (required) subdomain (%1), and first path element (%3), discard port number if present (%2)
RewriteCond %{HTTP_HOST}<>%{REQUEST_URI} ^([^.]+)\.mysite\.com(:80)?<>/([^/]*) [NC]
# Rewrite only when subdomain not equal to first path element (prevents mod_rewrite recursion)
RewriteCond %1<>%3 !^(.*)<>\1$ [NC]
# Rewrite to /subdomain/path
RewriteRule ^(.*) /$1/%1 [L]
my phpinfo tells me "posix: Revision $Revision: 1.51.2.2 $ "
so that means my server support's POSIX 1003.2 right?
[edited by: jdMorgan at 6:13 pm (utc) on June 18, 2005]
[edit reason] Example.com [/edit]
> File does not exist: /home//fst/var/www/html/timmy
I can't tell if the above path is otherwise correct or not. If you can identify the specific problem and provide details, then maybe we can help.
Jim
when i type in okay.bar.com/timmy it goes to /home/fst/var/www/html/okay/timmy, which is where i want it to go.
i just want to be able to get there by typing timmy.bar.com and not havve to type 'okay' at all
.
any assistance offered would be greatly appreciated.
RewriteEngine on
# Rewrite <subdomain>.example.com/<path> to example.com/<subdomain>[b]/okay[/b]/<path>
#
# Skip rewrite if no hostname or if subdomain is www
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\. [NC]
# Extract (required) subdomain (%1), and first path element (%3), discard port number if present (%2)
RewriteCond %{HTTP_HOST}<>%{REQUEST_URI} ^([^.]+)\.example\.com(:80)?<>/([^/]*) [NC]
# Rewrite only when subdomain not equal to first path element (prevents mod_rewrite recursion)
RewriteCond %1<>%3 !^(.*)<>\1$ [NC]
# Rewrite to /subdomain/path
RewriteRule ^(.*) [b]/okay/[/b]%1/$1 [L]
Jim
quick question:
how do i prevent the url from changing in the address bar?
currently, when i type timmy.bar.com - it goes to www.bar.com/okay/timmy
but the address bar will continue to show timmy.bar.com.
After clicking on a link though, it will show the full url.
how do i configure it so that the address bar always shows timmy.bar.com?
thanks