Forum Moderators: phranque

Message Too Old, No Replies

cut off parameters and redirect

moved permanently (301)

         

moon2005

11:36 pm on Aug 26, 2005 (gmt 0)

10+ Year Member



Hi,

I used to use a .php file which was requested like
http://example.com/index.php?content=xyz or
http://example.com/?content=xyz

Now, I'm using a simple .htm-file instead of the PHP-Script.
I don't want it to look like duplicate-content for search engines. That's why I want to redirect such requests with 301, moved permanently: http://example.com without any parameters.

Howto do that?

Thanks in advance.

jd01

12:24 am on Aug 27, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi moon2005,

The best place to start finding information is in the library - link is at the top left of pages. When you have something you have tried and cannot get to work, let us know and we will be glad to help you.

You will need to use QUERY_STRING to prevent an infinite loop. EG

RewriteCond %{QUERY_STRING} .
RewriteRule ^(index\.php)?$ http://yoursite.com [R=301,L]

Justin

jdMorgan

3:50 am on Aug 27, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



jdo1's being modest. He's the author of the library post you need: [webmasterworld.com...]
It's in the Apache Server section of the Library.

Add a trailing slash to the substitution URL to save your server a bit of work:


RewriteCond %{QUERY_STRING} .
RewriteRule ^(index\.php)?$ http://yoursite.com/ [R=301,L]

Jim