Forum Moderators: phranque

Message Too Old, No Replies

Rewriting subdomains to folders

I'm really in trouble

         

amjed

3:08 pm on May 21, 2007 (gmt 0)

10+ Year Member



hi,

i want to rederict a folder to subdomain. i have looked in all the forum but nothing worked for me. what i want to do is : when user request a http://blog1.example.com --------> http://example.com/blog1 but in his browser he must have a http://blog1.example.com address it worked forme but like this way when i type blog1.example.com it redirect to http://blog1.example.com/blogs/blog1

im looking for some thing like wordpress htaccess style .

this is my .htaccess:


RewriteEngine on
RewriteBase /

# If no-www domain requested, externally redirect to www domain
RewriteCond %{HTTP_HOST} ^example\.org
rewriterule (.*) http://www.example.org/$1 [R=301,L]

# If www+subdomain domain requested, externally redirect to subdomain without "www"
RewriteCond %{HTTP_HOST} ^www\.([^.]+)\.example\.org
rewriterule (.*) http://%1.example.org/$1 [R=301,L]

# If subdomain+www domain requested, externally redirect to subdomain without "www"
RewriteCond %{HTTP_HOST} ^([^.]+)\.www\.example\.org
rewriterule (.*) http://%1.example.org/$1 [R=301,L]

# If subdomain requested, rewrite home page requests to index.php with query string user=subdomain & page="home"
RewriteCond %{HTTP_HOST} !^www\.example\.org
RewriteCond %{HTTP_HOST} ^([^.]+)\.example\.org
rewriterule ^$ blogs/%1 [L]

and this the wordpress one : for who can make it work with sumple subdir :
RewriteEngine On
RewriteBase /

# Rewrite www.example.com to example.com
RewriteCond %{HTTP_HOST} ^www\.(.*)
RewriteRule ^(.*) http://%1/$1 [R,L]

#uploaded files
RewriteRule ^(.*/)?files/$ index.php [L]
RewriteRule ^(.*/)?files/(.*) wp-content/blogs.php?file=$2 [L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule . - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-.*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]


please help

and thanks
AL

[edited by: jdMorgan at 9:09 pm (utc) on May 21, 2007]
[edit reason] Example.com, tidied-up [/edit]

jdMorgan

1:18 pm on May 22, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The first step would be to delete this section (or comment it out) of the WordPress code, since you are already doing this in your own code:

# Rewrite www.example.com to example.com
RewriteCond %{HTTP_HOST} ^www\.(.*)
RewriteRule ^(.*) http://%1/$1 [R,L]

The rest is not clear, so please provide examples of what URLs you request, what filenames you want those URLs to serve, and what filenames they actually serve.

We need to know:

  • How did you test? (what URL-paths did you request?)
  • What did you expect? (what is the expected correct server filepath?)
  • What is the actual result? (what was the actual, incorrect filepath?)
  • How do the actual results differ from what you expected?

    Try to provide as much information as possible in that order, changing only the domain name (use example.com).

    Jim

  • g1smd

    11:21 pm on May 22, 2007 (gmt 0)

    WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



    >> # If subdomain+www domain requested, externally redirect to subdomain without "www" <<

    Do you ever get requests for something.www.domain.com then?

    I would find that very unlikely.

    I also wonder how your code you cope with www.www.domain.com in that case?