Forum Moderators: phranque
I recently created a subdomain for my website which I want to redirect to a certain set of PHP driven pages located in my primary domain's root directory. These pages rely on being in the primary domain's root to work, which is why I can't simply move them into the subdomain's root directory.
With this in mind, what kind of redirect should I implement in the subdirectory. Right now Im using htaccess redirect, which works fine, but Im not sure it's appropriate since I havent permanently moved anything, as the 301 error implies. I do want to redirect to basically tell the search engines like Google, "Hey don't index this page, start indexing at the page I'm redirecting you to."
Is htaccess ok for this, or is there another solution? Thanks for any help :-)
Your use of 301-Moved Permanently is correct in this case.
The use of the term "301 Error" is specific to MS IIS, AFAIK. 400-series server response codes indicate an error on the part of the requestor, e.g. 404 indicates the requestor is asking for a non-existant page. 300-series response codes are informational.
As long as you are redirecting to spiderable URLs in your site root directory, you should be fine. If you are redirecting to long, spider-unfriendly URLs, you might consider adding a "silent" internal redirect in your root from a spider-friendly URL in root to the type of URL required by the scripts in root. In this case, there is no requirement that a file exists to correspond to the spider-friendly URL - you are just using the friendly name as an alias, and the silent internal redirect will deliver the requests to the scripts.
subdirectory_domain--301 redirect-->spider_friendly_URL_in_root--internal redirect-->script_URL_in_root.
Jim
*************************
Redirect /index.html [xxxxxxx.com...]
Redirect /index.php [xxxxxxx.com...]
*************************
I think I'm being too redundant, especially since the index.html(php) files never existed. Would this be better:
******************************
Redirect [xxx.com...]
******************************
Appreciate the help :D
The directives you posted will result in a 302-Moved Temporarily redirect, so most spiders will continue to ask for the subdirectory, not the root directory. Is that what you want? If not, then use RedirectPermanent.
Redirect uses prefix matching, so you can just omit the "html" and "php":
Redirect /index. http://www.xxxxxxx.com/
- or even:
Redirect / http://www.xxxxxxx.com/
which would redirect everything. It's not necessary to have any other files in the subdirectory. You may not even need the subdirectory to exist; You could use .htaccess in root to redirect requests for that subdirectory directly to the scripts. I guess it all depends on how a spider gets into the subdirectory in the first place...
Jim
**************************
RedirectPermanent / [xxxxxxx.com...]
**************************
That appears to have done the trick. Thanks again for your help. :D