httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Doug Doidge" <ddoi...@ross-simons.com>
Subject [users@httpd] Newbie needs help with Apache Rewrite
Date Fri, 01 Feb 2008 15:02:02 GMT
Hello, I am a newbie (to the Apache rewrite rules) who has been thrown
into the lion's den. We are having trouble achieving our three goals
listed below. Any pointers would be greatly appreciated. 

 

We are having problems converting the incoming URL to a persistent,
SEO/spider-friendly URL while setting the old URL to a permanent 301
redirect. Any help would be greatly appreciated.

 

Our goal is to...

1) rewrite incoming alternate domains (ie- www.oursite.org) and old
sub-domains (ie- jewelry.oursite.com) to www.oursite.com.

2) in the URL, persist spider-friendly SEO links (ie-
"www.oursite.com/Diamond/Rings.html" is actually
"www.oursite.com/search.jsp?freeText=Diamond+Rings").

3) catch and convert old, dead links to their new pages/search results.

 

If the URL changed, the resulting URL, from the above three goals, would
return as a permanent 301 redirect.

 

Here is a sample of our Apache conf file...

 

-------------------------------------------------

 

RewriteEngine On

RewriteLog "apache/logs/rewrite.log"

RewriteLogLevel 0

 

# redirect everything to www except subdomains and internal use

RewriteCond %{HTTP_HOST}      !^www\.oursite\.com [NC]

RewriteCond %{HTTP_HOST}      !^$

RewriteRule .?   http://www.oursite.com%{REQUEST_URI} [R=301]

 

# Standard category links for use in navigation

RewriteRule ^/jewelry.html        /search.jsp?category=JEWELRY [NC,PT]

 

# old, now-deleted pages redirected to search engine

RewriteRule       /clearance.htm
http://www.oursite.com/search.jsp?freeText=Clearance [NC,R=301,L]

 

# keyword entry points

RewriteRule       ^/diamonds/$
http://www.oursite.com/search.jsp?freeText=Diamond [NC,R=301,L]

RewriteRule       ^/diamonds$
http://www.oursite.com/search.jsp?freeText=Diamond [NC,R=301,L]

 

# old static to new static pages

RewriteRule       ^/retail/$
http://www.oursite.com/content/retail.htm [NC,R]

RewriteRule       ^/retail$
http://www.oursite.com/content/retail.htm [NC,R]

RewriteRule       /content/shopping.htm
http://www.oursite.com/content/faq.htm [NC,R=301]

 

# Redirect SEO-optimized html paths to free-text searches, up to three
levels deep

RewriteCond %{REQUEST_URI}    ^/(.*)\/(.*)/(.*)\.html$ [NC]

RewriteRule ^.* /search.jsp?freeText=%1\+%2\+%3 [NC,PT]

RewriteCond %{REQUEST_URI}    ^/(.*)\/(.*)\.html$ [NC]

RewriteCond %{REQUEST_URI}    !^/includes\/page(.*)\.html$ [NC]

RewriteCond %{REQUEST_URI}    !^/routetest\/index\.html$ [NC]

RewriteRule ^.* /search.jsp?freeText=%1\+%2 [NC,PT]

 

# Redirect the root path to the new root

RewriteCond %{REMOTE_HOST}  !^100.100.100.100 [NC]

RewriteCond %{REMOTE_HOST}  !^101.101.101.101 [NC]

RewriteRule ^/$            http://www.oursite.com/ [R=301,L]

 

-------------------------------------------------

 

Thank you, Doug


Mime
View raw message