|
|||||||
New to SitePoint Forums? Register here for free!
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
SitePoint Enthusiast
![]() Join Date: Feb 2006
Posts: 32
|
I can point subdomains to subfolders, but not sub-subfolders. How can I?
I can point subdomains to subfolders, but not sub-subfolders. How can I?
Code:
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} ^([^.]+)\.hostingz\.org(: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]
But how do I modify the last line, the RewriteRule so that it redirects to sites/(then the subdomain). So http://subdomain.hostingz.org --> http://hostingz.org/sites/subdomain. How can it be done? And test it out first as Code:
RewriteRule sites/^(.*) /%1/$1 [L] Code:
RewriteRule sites^(.*) /sites/%1/$1 [L] |
|
|
|
|
|
#2 |
|
Follow Me On Twitter: @djg
![]() ![]() ![]() ![]() ![]() Join Date: Aug 2000
Location: Philadephia, PA
Posts: 19,741
|
The URL you're matching is "subdomain.hostingz.org", which does not contain the word "sites", so it doesn't make sense for "sites" to appear in your pattern (left side of the rule).
Code:
RewriteRule ^(.*) /%1/$1 [L] Code:
RewriteRule ^(.*) /sites/%1/$1 [L] |
|
|
|
|
|
#3 |
|
SitePoint Enthusiast
![]() Join Date: Feb 2006
Posts: 32
|
I tried it and I get this
Code:
Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. |
|
|
|
|
|
#4 |
|
Hosting
![]() ![]() ![]() ![]() Join Date: Feb 2002
Location: Auckland
Posts: 11,070
|
db,
Yeah, DON'T use the EVERYTHING atom unless you know what you're doing (i.e., know how to prevent looping on the @#$% thing)!Code:
RewriteCond %{REQUEST_URI} !^/?sites/
RewriteRule ^(.*) sites/%1/$1 [L]
Regards, DK |
|
|
|
|
|
#5 |
|
SitePoint Enthusiast
![]() Join Date: Feb 2006
Posts: 32
|
That code doesn't work either, but that's identical to the one Dan Grossman gave me.
|
|
|
|
|
|
#6 |
|
Hosting
![]() ![]() ![]() ![]() Join Date: Feb 2002
Location: Auckland
Posts: 11,070
|
db,
Except that it will NOT loop if sites is in the {REQUEST_URI}. Regards, DK |
|
|
|
|
|
#7 |
|
SitePoint Enthusiast
![]() Join Date: Feb 2006
Posts: 32
|
So whats the code then its still unresolved?
|
|
|
|
|
|
#8 |
|
Follow Me On Twitter: @djg
![]() ![]() ![]() ![]() ![]() Join Date: Aug 2000
Location: Philadephia, PA
Posts: 19,741
|
dklynn gave you a new RewriteCond to add, did you use it?
|
|
|
|
|
|
#9 |
|
SitePoint Enthusiast
![]() Join Date: Feb 2006
Posts: 32
|
Thank's alot dklynn and everyone else who helped me so a solution could be found.
I needed help because I've got a site builder account creator, and would like to create subdomains on the fly. Topic solved. Lock this thread. |
|
|
|
![]() |
| Bookmarks |
«
Previous Thread
|
Next Thread
»
| Thread Tools | |
| Display Modes | |
|
|
|
All times are GMT -7. The time now is 21:17.












EVERYTHING 


Linear Mode
