阿帕奇的.htaccess - 从URL切串并重定向阿帕奇、htaccess、URL

2023-09-02 11:40:08 作者:泪人怎笑

出于某种原因,谷歌收录几页我的网站为:

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

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

现在,我想重定向与Apache的.htaccess这些网页,以正确的URL:

Now, I want to redirect with apache .htaccess those pages to correct urls:

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

我GOOGLE和尝试了许多选择,但没有成功。 任何提示将是有益的。

I've googled and tried many options but with no success. Any tip will be helpful.

推荐答案

我已经加入到按照我的.htaccess文件行:

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.