Forum Moderators: phranque
I had a page which was dynamically generated for years with the URL, [mydomain.com...]
The page had a PR of 3.
However, I've now created a permanent server side redirect (a 301 redirect) to a new static HTML page that I've created to replace the old one. I've done 301 redirects on a number of other sites from one static page to another, and this has always worked great and preserved the PageRank.
The problem I'm encountering is that I can't figure out how to setup a RewriteRule and/or 301 redirect so that it properly redirects the old dynamic page's URL to my new static page.
This is what my .htaccess file looks like:
redirect 301 /cat--Wine-Gift-Baskets-Champagne-Beer--WINE [mydomain.com...]
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^shop_by_price--(.*) /cgi-bin/ccp51/cp-app.cgi?seo=shop_by_price--$1
RewriteRule ^cat--(.*) /cgi-bin/ccp51/cp-app.cgi?seo=cat--$1
RewriteRule ^item--(.*) /cgi-bin/ccp51/cp-app.cgi?seo=item--$1
RewriteRule ^page--(.*) /cgi-bin/ccp51/cp-app.cgi?seo=page--$1
RewriteRule ^store /cgi-bin/ccp51/cp-app.cgi?pg=store
#RewriteRule ^$ /cgi-bin/ccp51/cp-app.cgi RewriteRule ^index$ /cgi-bin/ccp51/cp-app.cgi?pg=ste_index_list
RewriteRule ^az-(.)-(.)$ /cgi-bin/ccp51/cp-app.cgi?pg=ste_index_az&startltr=$1&endltr=$2
RewriteRule ^sitemap.xml$ /cgi-bin/ccp51/cp-app.cgi?pg=ste_sitemap_proc
While my redirect DOES in fact redirect the old URL to the new one, I get this as the URL:
[mydomain.com...]
instead of this:
[mydomain.com...]
Consequently, my PR is not transferring.
I know that the screwed-up URL is a result of the Rewrite rule, but I don't know how to get around this.
I'm thinking that I can probably EXCLUDE the [mydomain.com...] URL with a RewriteCond but am unsure how to code this. I'm thinking something like this:
redirect 301 /cat--Wine-Gift-Baskets-Champagne-Beer--WINE [mydomain.com...]
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^shop_by_price--(.*) /cgi-bin/ccp51/cp-app.cgi?seo=shop_by_price--$1
RewriteCond {REQUEST_URI}!^/cat--Wine-Gift-Baskets-Champagne-Beer--WINE
RewriteRule ^cat--(.*) /cgi-bin/ccp51/cp-app.cgi?seo=cat--$1
RewriteRule ^item--(.*) /cgi-bin/ccp51/cp-app.cgi?seo=item--$1
RewriteRule ^page--(.*) /cgi-bin/ccp51/cp-app.cgi?seo=page--$1
RewriteRule ^store /cgi-bin/ccp51/cp-app.cgi?pg=store
#RewriteRule ^$ /cgi-bin/ccp51/cp-app.cgi RewriteRule ^index$ /cgi-bin/ccp51/cp-app.cgi?pg=ste_index_list
RewriteRule ^az-(.)-(.)$ /cgi-bin/ccp51/cp-app.cgi?pg=ste_index_az&startltr=$1&endltr=$2
RewriteRule ^sitemap.xml$ /cgi-bin/ccp51/cp-app.cgi?pg=ste_sitemap_proc
Any help you can provide would be immensely appreciated!
# Externally redirect dynamic URLs to static URLs only when requested by the client
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /cgi-bin/ccp51/cp-app\.cgi\?seo=shop_by_price--([^\ ]*)\ HTTP/
RewriteRule ^cgi-bin/ccp51/cp-app\.cgi$ http://www.example.com/shop_by_price--%1 [R=301,L]
#
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /cgi-bin/ccp51/cp-app\.cgi\?seo=cat--([^\ ]*)\ HTTP/
RewriteRule ^cgi-bin/ccp51/cp-app\.cgi$ http://www.example.com/cat--%1 [R=301,L]
#
# Internally rewrite static URLs to dynamic script filepath and query
RewriteRule ^shop_by_price--(.*)$ /cgi-bin/ccp51/cp-app.cgi?seo=shop_by_price--$1 [b][L][/b]
RewriteRule ^cat--(.*)$ /cgi-bin/ccp51/cp-app.cgi?seo=cat--$1 [b][L][/b]
GET /cgi-bin/ccp51/cp-app.cgi?seo=shop_by_price--foo HTTP/1.1
Also, note that for the dynamic URL redirects, it may be possible to use one rule to redirect all of them if the friendly URL is always exactly the same as the "seo=" value. Example:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /cgi-bin/ccp51/cp-app\.cgi\?seo=([^\ ]+)\ HTTP/
RewriteRule ^cgi-bin/ccp51/cp-app\.cgi$ http://www.example.com/%1 [R=301,L]
Jim