You are here: rewriting URLs, part II -- 301 redirect from old dynamic URLs « All PHP « IT news, forums, messages
rewriting URLs, part II -- 301 redirect from old dynamic URLs

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация