httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Doug Doidge" <>
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- and old
sub-domains (ie- to

2) in the URL, persist spider-friendly SEO links (ie-
"" is actually

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 .?{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 [NC,R=301,L]


# keyword entry points

RewriteRule       ^/diamonds/$ [NC,R=301,L]

RewriteRule       ^/diamonds$ [NC,R=301,L]


# old static to new static pages

RewriteRule       ^/retail/$ [NC,R]

RewriteRule       ^/retail$ [NC,R]

RewriteRule       /content/shopping.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}  !^ [NC]

RewriteCond %{REMOTE_HOST}  !^ [NC]

RewriteRule ^/$   [R=301,L]




Thank you, Doug

View raw message