如何删除一个?使用 301 重定向从带有 htaccess 的 url

发布于 2024-09-29 06:08:00 字数 516 浏览 0 评论 0原文

我需要一个 htaccess 301 重定向来从这个 url:

http://www.example.com/index.php/?content/page1

http://www.example.com/content/page1

我当前的 htaccess 规则是:

RewriteBase /    
RewriteCond %{HTTP_HOST} !="" 
RewriteRule ^index.php(/.*)$ http://%{HTTP_HOST}$1 [R=301]

问题是我得到这样的 url:

http://www.example.com/?content/page1

如何从 url 中删除问号 (?)。这也适用于该模式中的大约 20 个不同的 url。我希望该规则适用于我所有在此模式中需要为 301 的 url。

I need an htaccess 301 redirect for dynamic urls going from this url:

http://www.example.com/index.php/?content/page1

to

http://www.example.com/content/page1

My current htaccess rule is:

RewriteBase /    
RewriteCond %{HTTP_HOST} !="" 
RewriteRule ^index.php(/.*)$ http://%{HTTP_HOST}$1 [R=301]

the problem is I get urls like this:

http://www.example.com/?content/page1

How can I remove that question mark (?) from the url. Also this is for about 20 different urls in this pattern. I would like the rule to work for all my urls needing to be 301 in this pattern.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

揪着可爱 2024-10-06 06:08:00

? 结束目标。

RewriteRule ^index.php(/.*)$ http://%{HTTP_HOST}$1? [R=301]

End the target in a ?.

RewriteRule ^index.php(/.*)$ http://%{HTTP_HOST}$1? [R=301]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文