HTACCESS 问:如何将index.php?id=directory/indext.html 重定向到一个目录?
我似乎无法通过 .htaccess 将更复杂的链接重定向到目录(内部有 index.php)。由于 URL 又丑又长,我已经重建并更改了网站的文件:
旧:www.mysite.com/index.php?id=directory/index.html
新:www.mysite.com /目录/ (顺便说一下,其中包含index.php,而不再是.html)。
我还有很多目录,不仅仅是一个我想将旧链接重定向到新目录的目录,但它们在域名后面都有丑陋的index.php?id=somedirectory/index.html。
由于我彻底改变了我的网站,旧的和丑陋的 URL 打开了我的主页,丑陋的 URL 仍然在地址栏中,因为它们都曾经使用网站根目录中的主 .index.php 。对于 SEO 来说,重复内容是一大禁忌。
顺便说一句,我不使用数据库。我现在使用带有 include() 等的简单 PHP 文件。它不是一个带有会员帐户等的 WordPress 网站。我的网站静态多于动态。
我希望这不会太令人困惑。我并不是想缩短与 HTACCESS 的链接。我正在尝试永久重定向(301?)。
谢谢您的宝贵时间。
I can't seem to redirect more complex links to directories (with index.php inside) through .htaccess. I have reconstructed and changed files to my site because of the ugly and long URLs:
Old: www.mysite.com/index.php?id=directory/index.html
New: www.mysite.com/directory/
(with index.php in it, by the way, and not .html anymore).
I also have many directories and not just one that I would like to redirect old links to the new ones, but they all had the ugly index.php?id=somedirectory/index.html after the domain.
Since I have drastically changed my website, the old and ugly URLs open up my homepage with the ugly URL still in the address bar since they all used to use the main .index.php in the root of the site. That's a big no-no for SEO as duplicate content.
By the way, I don't use databases. I use simple PHP files with include() and such now. It's not a WordPress site with member accounts, etc. My website is more static than dynamic.
I hope this is not too confusing. I'm not trying to shorten links with HTACCESS. I'm trying to redirect permanently (301?).
Thank you for your time.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这应该可以:
它对我有用!
您还需要:
上面的声明。
This should do:
It works for me!
You will also need:
Above the previous statement.