Posted by web_design on 07/31/05 05:24
I have been trying to rewrite my PHP dynamic URLs from something like this:
www.mywebsite1234.com/index.php?p=page1
to something like this:
www.mywebsite1234.com/page1.htm
I have gotten this to work (with the help of people in this newsgroup)...
But now I have two URLs with the exact same content and Google doesn't like
it (the old dynamic URLs still work, along with the new "static" ones). Is
there a way to add a line to the htaccess file so that all of the old
dynamic URLs will become 301 redirects to the new pages?
This is how my .htaccess file looks so far. I've tried a few variations on
the "RedirectMatch 301" line but it's not working. I get a "200 ok"
response from the old URLs and not the desired "301 permanantly moved". Any
suggestions? I'm new to regular expressions so I'm not sure if I'm doing it
right.
-----------------------------------------------------------------------
# This part works:
RewriteEngine On
RewriteRule ^(.+)(\.htm)$ /index.php?p=$1 [L]
# This is the part that doesn't work:
RedirectMatch 301 /index.php?p=(.*)$ http://www.mywebsite1234.com$1.htm
Navigation:
[Reply to this message]
|