Forum Moderators: phranque

Message Too Old, No Replies

.htaccess php parameters redirect

         

junglesnail

9:19 am on Jul 7, 2010 (gmt 0)

10+ Year Member



Hi guys,

I found some similar topics on this problem, but it seems i can't post there.

I redesigned someone's website and search engines still have the old pages in cache.
Most of the old pages look like
/index.php?page=photos&id=1
or
/index.php?page=contacts
I'm trying to redirect all this pages to my home page. ( so
/index.php?page=photos&id=1 has to take me to / )
I can't make it work. I'm no good at .htaccess scripting, so don't laught :).
Here's the last thing i tried :
RewriteRule ^index(.*)$ / [R=301,L]
I don't know how to get rid of the parameters.
Please help.

g1smd

10:10 am on Jul 7, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Identical question asked 14 hours before yours...

[webmasterworld.com...]

Same answer applies.

junglesnail

10:20 am on Jul 7, 2010 (gmt 0)

10+ Year Member



Thank you and sorry.
Then, how can i redirect all the pages to an error page with a noindex meta tag ? Because now, when i access /index.php?page=photos&id=1 it displays by default the content of my home page ( index ) and search engines already see this as duplicate content. Where should i redirect these pages to ?

g1smd

3:19 pm on Jul 7, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



It is likely you'll need to adjust the PHP script so that when a requested URL has no matching entry in the database, the PHP script itself sends the HTTP 404 header to the browser and then "includes" the HTML for the error message page too.

junglesnail

3:19 pm on Jul 7, 2010 (gmt 0)

10+ Year Member



The problem is that i have to make a redirect from those pages, because they all display my home page content. How can i redirect eg: index.php?page=photos%id=1 to a 404 not found page ?

junglesnail

3:24 pm on Jul 7, 2010 (gmt 0)

10+ Year Member



sorry i posted in the same time.
Isn't there any way to do this through .htaccess? It seems a lot more easier, i have only 9 pages like that that need to be redirected; it seems like the others haven't been cached by google.
I've been trying different methods but i can't get anything to work.

jdMorgan

3:40 am on Jul 10, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The other thread contains some new info I posted about 'removed resources' which will be useful with this code snippet:

# Return proper 410-Gone response for removed "/index.php?page=" resources
RewriteCond %{QUERY_STRING} ^page=photos&id=1$ [OR]
RewriteCond %{QUERY_STRING} ^page=contacts$
RewriteRule ^(index\.php)?$ - [G]

Jim