Forum Moderators: Robert Charlton & goodroi
I have a subdomain to promote; say sub.domain.com: I set up properly .htaccess file and also added robots.txt file but...
Google still see domain.com/sub/ !
Why this happens? I could forbid the access to that directory via robots.txt file but in that way Google doesn't scan it anymore...
Am I wrong?
Thanks for any useful suggestion
Regards
You'll need that redirect.
here is my .htaccess file; I added the redir command (bolded text) as below:
# -FrontPage-IndexIgnore .htaccess */.?* *~ *# */HEADER* */README* */_vti*
Order deny,allow
<Limit GET POST>
Allow from all
</Limit><Limit PUT DELETE>
Deny from all
</Limit>AuthName www.domain.net
AuthUserFile /home/user/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/user/public_html/_vti_pvt/service.grp
AddType application/x-httpd-cgi .htmredirect permanent /sub [sub.domain.net...]
Options -Indexes +FollowSymLinks
RewriteEngine on# Redirect all non-canonical domain requests to requested resource in canonical domain
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST}!^www\.domain\.net
RewriteCond %{HTTP_HOST}!^sub\.domain\.netRewriteRule (.*) [domain.net...] [R=301,L]
It works fine, but as I never managed such a problem before,I'm not sure is a technically correct solution:
What do you think about?
.
For instance, what happens if the site has canonicalisation of index files in place, and you then ask for the index file in that folder?
You would have a redirect to take care of the index file, and another redirect to take care of the folder itself. One redirect runs, and then the other one. That is a redirection chain and is something to be avoided. The redirect should really solve both problems in just one move.
RewriteRule (.*) [sub.domain.net...] [R=301,R]
RewriteRule (.*) [domain.net...] [R=301,L]
but it doesn't work.It's the reason for wich I set up that redorect permanent code.
I don't know much about rewrite rules...
To "publish" a subdomain, as I understand it, you need either to have set up wildcard DNS or to specify a specific subdomain in your A-records. Your .htacess then might come into play, depending on your preferences and how your subdomains are set up.
What's being done on the DNS now?
### BELOW IS MOD_ALIAS (Redirect permanent) ###
redirect permanent /sub http://sub.domain.net
Options -Indexes +FollowSymLinks
### BELOW IS MOD_REWRITE (RewriteRule) ###
RewriteEngine on
# Redirect all non-canonical domain requests to requested resource in canonical domain
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\.domain\.net
RewriteCond %{HTTP_HOST} !^sub\.domain\.net
RewriteRule (.*) http://www.domain.net/$1 [R=301,L]
Mod_Alias and Mod_Rewrite directives will be processed in different orders, depending on server configuration, not on rule order. So, it is entirely possible there is a processing order issue.
I would recommend changing everything to Mod_Rewrite and making things a little more efficient:
Options -Indexes +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} !^(www¦sub\.domain\.net)?$
RewriteRule (.*) http://www.domain.net/$1 [R=301,L]
RewriteRule ^sub/(.*) http://sub.domain.net/$1 [R=301,L]
For more details see the Apache Forum...
Justin