【问题标题】:Remove special character ? from url with .htaccess删除特殊字符?从带有 .htaccess 的 url
【发布时间】:2014-09-10 22:06:35
【问题描述】:

我想重定向这个网址:

http://www.domena.pl/?tekst,123.html

到这里

http://www.domena.pl/tekst,123.html

我只想删除?在第一个 / 之后,所以我想将每个 url domena/?...... 重定向到 domena/......

我正在使用这个 htaccess,它适用于 domena/testtekst,123,但我不知道应该如何更改它以使用特殊字符?

RewriteCond %{HTTP_HOST} ^www.domena.pl$
RewriteCond %{REQUEST_URI} ^/test(.*)$
RewriteRule ^test(.*)$ http://www.domena.pl/$1 [L,R=301] 

这不起作用:

RewriteCond %{HTTP_HOST} ^www.domena.pl$
RewriteCond %{REQUEST_URI} ^/?(.*)$
RewriteRule ^?(.*)$ http://www.domena.pl/$1 [L,R=301] 

这也不起作用:

RewriteCond %{HTTP_HOST} ^www.domena.pl$
RewriteCond %{REQUEST_URI} ^/\?(.*)$
RewriteRule ^\?(.*)$ http://www.domena.pl/$1 [L,R=301] 

【问题讨论】:

    标签: .htaccess mod-rewrite redirect


    【解决方案1】:

    你可以使用:

    RewriteEngine On
    
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+\?([^\s&]+) [NC]
    RewriteRule ^ /%1? [R=302,L,NE]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-07-22
      • 2019-01-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-30
      • 2014-05-27
      • 1970-01-01
      相关资源
      最近更新 更多