Forum Moderators: phranque
I have a website with the files in the root directory, it has a Google page rank of 5.
example.com/
I have a blog with the files in a subdirectory, it has a page rank of 4.
example.com/serendipity/
I want the existing external links to end up at the blog with the domain page rank of 5. Though at the point of frustration I am with this, I don't care that much about the page rank anymore! :)
I use the following 301 in the htaccess file of the root.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com
RewriteRule ^(.*)$ http://example.com/serendipity/$1 [R=permanent,L]
My problem is that the page rank does not carry over and I can no longer access the website which I want people to do from my internal links. I assume my problem is that the 301 not only redirects example.com, but also example.com/index.htm(l).
Anyone know how I am screwing this up?
RJ
[edited by: jdMorgan at 5:07 pm (utc) on May 12, 2007]
[edit reason] example.com, please, See TOS. [/edit]
Each time a redirect is invoked, the current HTTP transaction is terminated, and the client (e.g. browser) starts a new HTTP request with the new URL given in the redirect response; The server itself does not remember anything about any previous requests, so there's nothing to stop this loop.
You'll need to tell it NOT to redirect /serendipity, so that this redirect happens only once:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com
RewriteCond $1 !^serendipity/
RewriteRule (.*) http://example.com/serendipity/$1 [R=301,L]
Also, if you wish *all* requests for example.com to go to the forum, and you cannot move the forum into the root directory (or don't want to), but you don't want or need the forum's subdirectory (serendipity) to appear in the URL, then use this instead:
RewriteEngine on
#
# If direct client request for forum subdirectory
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /serendipity
# externally redirect back to main domain
RewriteRule ^serendipity/(.*)$ http://example.com/$1 [R=301,L]
#
# Internally rewrite all requests to forum subdirectory
RewriteCond %{HTTP_HOST} ^example\.com
RewriteCond $1 !^serendipity/
RewriteRule (.*) /serendipity/$1 [L]
Jim