TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   General (http://www.talkphp.com/general/)
-   -   Htaccess or PHP? (http://www.talkphp.com/general/4802-htaccess-php.html)

Germanium 07-30-2009 06:31 PM

Htaccess or PHP?
 
Ok I have a site that I'm trying to build up and basically it's been running off the temporary url that my host offers for when the dns resolves it's built some traffic on that url.

What I want to do is make it so that people can still acess urls on that site, but if google comes around it shows a 301 redirect. Right now I'm doing this with a 301 redirect with htaccess so that all urls are sent to the domain.

What I'd like is to have htaccess do a 301 for all urls except the main page, so that if user enters http://subdomain.host.com it shows them the site but when google comes to the page it tells them 301 to the actual domain. All other urls on that subdomain should 301 to the domain.

So basically I need either an htaccess or php way of making it so that just the main page is accessible on the subdomain, and that all other urls are directed through the domain.

Current Htaccess:
Code:

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(.*)sub.host.com [NC]
RewriteRule ^(.*)$ http://mydomain.com/$1 [R=301,L]

ErrorDocument 404 /404.php
ErrorDocument 500 /404.php
ErrorDocument 502 /404.php

I was thinking htaccess could be used to allow 1 url to be accessible on the subdomain and all others 301 to the domain. Then I would write some php on the main file to detect the url entered and if subdomain and google - 301 to the main domain with headers.


Need some help ^^ +rep for good advice

Germanium 07-31-2009 09:57 PM

can anyone help?


All times are GMT. The time now is 06:57 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0