【问题标题】:How to remove a ? from a url with htaccess using 301 redirect如何删除一个?从带有 htaccess 的 url 使用 301 重定向
【发布时间】:2010-10-27 08:31:45
【问题描述】:

我需要一个 htaccess 301 重定向来处理来自这个 url 的动态 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]

问题是我得到这样的网址:

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

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

【问题讨论】:

  • 请使用代码块。

标签: .htaccess


【解决方案1】:

?结束目标。

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

【讨论】:

  • 感谢伊格纳西奥的回复。那使我的原始网址重定向到主页而不是新网址。要回答你的问题,我不想要任何?在网址中。如果有帮助,我们正在使用 Codeigniter 框架。
猜你喜欢
  • 2011-09-02
  • 1970-01-01
  • 1970-01-01
  • 2023-03-27
  • 1970-01-01
  • 1970-01-01
  • 2012-08-29
  • 2018-01-22
  • 1970-01-01
相关资源
最近更新 更多