-1

I have a PHP website where content is generated & shown on the website from SQL. File index.php uses pagination. Due to this a lot of pages generated about 1800 (index.php?page=1800) which got indexed in search engines instead of real content pages.

I want to change this & show a custom homepage(index.php) so the user can select content from category.

I know this page redirect can be done using .htaccess. something like this.

RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteRule ^(.*)index.php$ http://www.example.com/$1 [R=301,L]

I want all index.php?page=xxxx redirect to index.php

As changing on live website can be dangerous also effect search results. So need some guidance, to do this in effective way and its impact on search results. If the old indexed pages can be removed from Google (if possible).

Vehlad
  • 155
  • 2
  • 10
  • 20
  • 1
    Pure code-writing requests are off-topic on Stack Overflow — we expect questions here to relate to *specific* programming problems — but we will happily help you write it yourself! Tell us [what you've tried](https://stackoverflow.com/help/how-to-ask), and where you are stuck. This will also help us answer your question better. – Daz Jun 06 '19 at 06:58
  • _“I want all index.php?page=xxxx redirect to index.php”_ - then your pagination would stop working completely, is that really what you want? – 04FS Jun 06 '19 at 08:00
  • _“As changing on live website can be dangerous also effect search results. So need”_ to set up a proper dev/staging system. That is the proper continuation of that sentence, yes. – 04FS Jun 06 '19 at 08:02
  • @04FS yes, i want to stop pagination on homepage and static homepage. – Vehlad Jun 06 '19 at 08:16
  • https://stackoverflow.com/questions/13073253/how-to-redirect-urls-based-on-query-string, https://perishablepress.com/redirect-query-string-htaccess/, https://www.google.com/search?q=htaccess+redirect+based+on+specific+query+string+site:stackoverflow.com – 04FS Jun 06 '19 at 08:19
  • @Daz sir, no pure code writing request here. I already know the code just want some suggestions regarding implementation on live site. now updated with example code. – Vehlad Jun 17 '19 at 08:49

1 Answers1

0

I solved this by using this code:

RewriteCond %{QUERY_STRING} ^page=(.+)$ [NC]
RewriteRule ^index.php$ /? [L,R=301,NC]

but still not sure what to do with pages already indexed by search engine.

Vehlad
  • 155
  • 2
  • 10
  • 20