Forum Moderators: phranque

Message Too Old, No Replies

htaccess subdomain page

htaccess

         

sgr2000

6:44 pm on Aug 5, 2011 (gmt 0)

10+ Year Member



I have a subdomain at
virginia.mydomain.com

and in my webmaster tools I see that I am getting error for pages that should be on root domain. for ex

mydomain.com/mississipi/ms-maps.html is where the page is really located.

Google Webmaster tools for virginia.mydomain.com shows and error to
virginia.mydomain.com/mississipi/ms-maps.html

how do I redirect anything under
virginia.mydomain.com/mississipi/
to
mydomain.com/mississipi/

I have tried

Redirect 301 /mississippi/.* [mydomain.com...] [R=301,L]
and
RedirectMatch 301 ^/mississippi/(.*)$ [mydomain.com...]

but neither works... help

lucy24

8:13 pm on Aug 5, 2011 (gmt 0)

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



Before you do anything, take a closer look at GWT. There's a column that says where the not-found page is linked from. If they're all external links from sites that have nothing to do with you there's nothing you can do about it, but if there are bad links on your own site you need to clean those up first.

mod_alias automatically completes the address for you; you don't need to capture anything. And you definitely don't want an un-captured .* because then it would simply disappear. Or rather it would, if your "Redirect 301" version were legal. It isn't; only RedirectMatch and mod_rewrite allow Regular Expressions. The [R=301,L] element also goes with mod_rewrite, so you've got your commands garbled.

Do the root domain and the subdomain pass through the same htaccess? If so, you will need to use mod_rewrite with a RewriteCond to ensure you don't go into an infinite loop.

g1smd

8:21 pm on Aug 5, 2011 (gmt 0)

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



The .htaccess file for this redirect needs to go in the /mississippi/ folder and needs to be aware what the requested domain was, otherwise you will have an infinite loop.

Do not use Redirect or RedirectMatch here. Use a RewriteRule with a preceding RewriteCond detecting the requested hostname.

sgr2000

8:27 pm on Aug 5, 2011 (gmt 0)

10+ Year Member



No Sub and root have different htaccess files


from GWT
Detail 404 (Not found)
from Pages that link to [virginia.n2genealogy.com...]

page is really located at [n2genealogy.com...] so I need a RewriteRule with a preceding RewriteCond rule for
[virginia.n2genealogy.com...] to [n2genealogy.com...]

g1smd

8:38 pm on Aug 5, 2011 (gmt 0)

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



In your head you need to separate out the two concepts of "internal server filepaths" and "URLs used out on the web". They are two separate things.

Leading parts of the URL are stripped ("localised") in per-directory context before being presented to the RewriteRule for processing.

sgr2000

8:55 pm on Aug 5, 2011 (gmt 0)

10+ Year Member



how about
rewritecond %{HTTP_HOST} !^virginia\.n2genealogy\.com\mississippi\$ [NC]
RewriteRule ^mississippi/ [n2genealogy.com...] [R=301,L]

sgr2000

8:55 pm on Aug 5, 2011 (gmt 0)

10+ Year Member



nm, it dosent work

lucy24

9:18 pm on Aug 5, 2011 (gmt 0)

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



Does it continue not to work if you fix the two wrong backslashes in the RewriteCond? (I assume it still won't, but it will not-work in a different way.)

:: wandering off to figure out what the ### my host did with my Access Logs, which I just detoured to look at because the Error Log shows the actual path while Access Log only gives the part after the domain name ::

g1smd

9:23 pm on Aug 5, 2011 (gmt 0)

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



HTTP_HOST looks only at hostname. It cannot see paths or query strings.

sgr2000

11:52 pm on Aug 5, 2011 (gmt 0)

10+ Year Member



can you take the example I gave and give me a possible working example?