Forum Moderators: phranque
i have create dynamic subdomain system
after some Amendments in htaccess, httpd.conf and server
and it work well
but i want to register at google webmastertool with my subdomains
but what about "robots.txt" and "authentication file"
what i can do in htaccess file to fix this problem
http://dynamic.example.com/robots.txt
my htaccess file ;
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.mysite.com
RewriteCond %{HTTP_HOST} ([^.]+)\.mysite.com
RewriteRule ^(.*)$ /home/user/public_html/category.php?slug=%1
[edited by: jdMorgan at 8:27 pm (utc) on Feb. 20, 2009]
[edit reason] example.com [/edit]
RewriteEngine on
#
# Externally redirect to canonicalize the main domain
RewriteCond %{HTTP_HOST} ^example\.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www\.example\.com\. [NC,OR]
RewriteCond %{HTTP_HOST} ^www\.example\.com:[0-9]+$ [NC]
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
#
# Externally redirect to canonicalize subdomains
RewriteCond %{HTTP_HOST} ^www\.([^.]+)\.example\.com [NC,OR]
RewriteCond %{HTTP_HOST} ^([^.]+)\.www\.example\.com [NC,OR]
RewriteCond %{HTTP_HOST} ^([^.]+)\.example\.com\. [NC,OR]
RewriteCond %{HTTP_HOST} ^([^.]+)\.example\.com:[0-9]+ [NC]
RewriteRule (.*) http://%1.example.com/$1 [R=301,L]
#
# Internally rewrite subdomain special file requests to /home/user/public
# folder with "sub-<subdomain>-" prefix on filename. Example:
# foo.example.com/robots.txt --> /home/user/public_html/sub-foo-robots.txt
RewriteCond %{HTTP_HOST} !^www\.example\.com
RewriteCond %{HTTP_HOST} ^([^.]+)\.(www\.)?example\.com
RewriteCond $1 ^robots\.txt$ [OR]
RewriteCond $1 ^sitemap\.xml$ [OR]
RewriteCond $1 ^google[0-9a-f]{16}\.html$ [OR]
RewriteCond $1 ^y_key_[0-9a-z]{16}\.html$ [OR]
RewriteCond $1 ^LiveSearchSiteAuth\.xml$
RewriteRule (.*) /home/user/public_html/sub-%1-$1 [L]
#
# Internally rewrite all other subdomain requests to script
RewriteCond $1 !^sub-
RewriteCond %{HTTP_HOST} !^www\.example\.com
RewriteCond %{HTTP_HOST} ^([^.]+)\.(www\.)?example\.com
RewriteRule (.*) /home/user/public_html/category.php?slug=%1 [L]
when i goto :
[sub.example.com...]
OR
[sub.example.com...]
OR any file after subdoamin url [sub.example.com...]
all urls 's result is :
[sub.example.com...] but no redirect
and i did't get the file's content
sorry , for my language
[sub.example.com...] = [sub.example.com...]
# Internally rewrite subdomain special file requests to /home/user/public
# folder with "sub-<subdomain>-" prefix on filename. Example:
# foo.example.com/robots.txt --> /home/user/public_html/sub-foo-robots.txt
You can simplify this line
RewriteCond %{HTTP_HOST} ^([^.]+)\.(www\.)?example\.com RewriteCond %{HTTP_HOST} ^([^.]+)\.example\.com Jim
but when i goto :
[subdomain.example.com...]
i can't see the "sub-subdomain-robots.txt" file's content
but i get :
[subdomain.example.com...] 's content
why the "sub-subdomain-robots.txt" file's content not display
RewriteRule (.*) http://www.example.com/sub-%1-$1 [R=302,L] If that works, then you may want to try
RewriteRule (.*) /sub-%1-$1 [L] Jim
===================
RewriteCond %{HTTP_HOST} ^example\.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www\.example\.com\. [NC,OR]
RewriteCond %{HTTP_HOST} ^www\.example\.com:[0-9]+$ [NC]
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www\.([^.]+)\.example\.com [NC,OR]
RewriteCond %{HTTP_HOST} ^([^.]+)\.www\.example\.com [NC,OR]
RewriteCond %{HTTP_HOST} ^([^.]+)\.example\.com\. [NC,OR]
RewriteCond %{HTTP_HOST} ^([^.]+)\.example\.com:[0-9]+ [NC]
RewriteRule (.*) [%1.example.com...] [R=301,L]
RewriteCond %{HTTP_HOST} !^www\.example\.com
RewriteCond %{HTTP_HOST} ^([^.]+)\.example\.com
RewriteCond $1 ^robots\.txt$ [OR]
RewriteCond $1 ^sitemap\.xml$ [OR]
RewriteCond $1 ^google[0-9a-f]{16}\.html$ [OR]
RewriteCond $1 ^y_key_[0-9a-z]{16}\.html$ [OR]
RewriteCond $1 ^LiveSearchSiteAuth\.xml$
RewriteRule (.*) /home/user/public_html/sub-%1-$1 [L]
RewriteCond $1 !^sub-
RewriteCond %{HTTP_HOST} !^www\.example\.com
RewriteCond %{HTTP_HOST} ^([^.]+)\.example\.com
RewriteRule (.*) /home/user/public_html/category.php?slug=%1 [L]
===================
I'm sorry for tired you (weak language :))
===================
RewriteCond %{HTTP_HOST} ^example\.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www\.example\.com\. [NC,OR]
RewriteCond %{HTTP_HOST} ^www\.example\.com:[0-9]+$ [NC]
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www\.([^.]+)\.example\.com [NC,OR]
RewriteCond %{HTTP_HOST} ^([^.]+)\.www\.example\.com [NC,OR]
RewriteCond %{HTTP_HOST} ^([^.]+)\.example\.com\. [NC,OR]
RewriteCond %{HTTP_HOST} ^([^.]+)\.example\.com:[0-9]+ [NC]
RewriteRule (.*) [%1.example.com...] [R=301,L]
RewriteCond %{HTTP_HOST} !^www\.example\.com
RewriteCond %{HTTP_HOST} ^([^.]+)\.example\.com
RewriteCond $1 ^robots\.txt$ [OR]
RewriteCond $1 ^sitemap\.xml$ [OR]
RewriteCond $1 ^google[0-9a-f]{16}\.html$ [OR]
RewriteCond $1 ^y_key_[0-9a-z]{16}\.html$ [OR]
RewriteCond $1 ^LiveSearchSiteAuth\.xml$
RewriteRule (.*) http://www.example.com/sub-%1-$1 [R=302,L]
RewriteCond $1 !^sub-
RewriteCond %{HTTP_HOST} !^www\.example\.com
RewriteCond %{HTTP_HOST} ^([^.]+)\.example\.com
RewriteRule (.*) /home/user/public_html/category.php?slug=%1 [L]
===================
RewriteCond %{HTTP_HOST} !^www\.example\.com
RewriteCond %{HTTP_HOST} ^[b]([^.]+)[/b]\.example\.com
RewriteCond $1 ^robots\.txt$ [OR]
RewriteCond $1 ^sitemap\.xml$ [OR]
RewriteCond $1 ^google[0-9a-f]{16}\.html$ [OR]
RewriteCond $1 ^y_key_[0-9a-f]{16}\.html$ [OR]
RewriteCond $1 ^LiveSearchSiteAuth\.xml$
RewriteRule (.*) http://www.example.com/sub[b]-%1-[/b]$1 [R=302,L]
However, the back-reference to $1 (value="robots.txt") *did* work when you tested it, and you did get a redirect as expected, but with the subdomain-name value missing.
There is no reason for this rule to fail in that way, and the only thing I can think of is some sort of character-encoding problem. You might want to very carefully re-type both lines into your code, and be sure to use a simple plain-text editor such as Windows NotePad to do this.
If it is not a character-encoding problem, I don't know what the problem could be... :(
Jim
Side note: One reason that RewriteConds are not processed until *after* the RewriteRule pattern matches is so that RewriteConds can use $1-$9 variables created in the RewriteRule. But since the RewriteRule substitution isn't invoked until after the RewriteCond patterns also match, the RewriteRule can make use of the %1-%9 back-references created by the last-matched RewriteCond.
Jim