apache .htaccess - cut a string from url and redirect

前端 未结 2 2030
别那么骄傲
别那么骄傲 2021-01-24 08:05

For some reason google indexed several pages of my website as:

http://myapp.com/index.php/this-can-be-enything/1234

Now, I want to redirect wit

相关标签:
2条回答
  • 2021-01-24 08:27

    I've added to my .htaccess file following lines:

    RewriteCond %{THE_REQUEST} ^.*index.php.*
    RewriteRule ^(.*)index.php(.*)$ $1$2 [NC,R=301,L]
    

    I don't know if this is best solution but works ok for me.

    0 讨论(0)
  • 2021-01-24 08:47

    Two Parts of problem

    1. To make Google aware that indexed page is moved to some other destination you need to handle that @ apache level and issue 301 ( moved permanently )

    2. Handler to handle the cached requested URL to new URL using the #1 handler itself.

    0 讨论(0)
提交回复
热议问题