apache .htaccess - 从 url 中剪切字符串并重定向
由于某种原因,谷歌将我网站的几个页面索引为:
http://myapp.com/index.php/this-can-be-enything/1234
现在,我想使用 apache .htaccess 重定向这些页面以更正网址:
http://myapp.com/this-can-be-enything/1234
我已经用谷歌搜索并尝试了很多选项,但没有成功。 任何提示都会有所帮助。
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 with apache .htaccess those pages to correct urls:
http://myapp.com/this-can-be-enything/1234
I've googled and tried many options but with no success.
Any tip will be helpful.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我已在 .htaccess 文件中添加了以下几行:
我不知道这是否是最佳解决方案,但对我来说效果很好。
I've added to my .htaccess file following lines:
I don't know if this is best solution but works ok for me.
问题的两个部分
要让Google知道索引页面已移动到其他目的地,您需要处理@apache级别和问题301(永久移动)
使用 #1 处理程序本身将缓存的请求 URL 处理为新 URL 的处理程序。
Two Parts of problem
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 )
Handler to handle the cached requested URL to new URL using the #1 handler itself.