从查询字符串中删除字符
Remove characters from query string
我需要重定向
http://example.com/page/?Id=1253-23098-
到
http://example.com/page/1253-23098
此重定向还包括从查询字符串末尾删除“-”。
我所做的是
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/page/$
RewriteCond %{QUERY_STRING} ^Id=([0-9\-[=12=]-9]*)$
RewriteRule ^(.*)$ http://example.com/page/%1? [L,R=301]
将我重定向到
http://example.com/page/1253-23098-
我需要从查询字符串中删除“1253-23098”之后的所有内容。
我在谷歌上搜索了过去 3-4 个小时,但似乎没有任何效果。
感谢任何帮助。
尝试:
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/page/?$
RewriteCond %{QUERY_STRING} ^Id=([0-9]*)-([0-9]*)-$
RewriteRule ^(.*)$ http://example.com/page/%1-%2? [L,R=301]
您可以使用:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^Id=(\d+-\d+) [NC]
RewriteRule ^page/?$ page/%1? [NC,L,R=301]
我需要重定向
http://example.com/page/?Id=1253-23098-
到
http://example.com/page/1253-23098
此重定向还包括从查询字符串末尾删除“-”。
我所做的是
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/page/$
RewriteCond %{QUERY_STRING} ^Id=([0-9\-[=12=]-9]*)$
RewriteRule ^(.*)$ http://example.com/page/%1? [L,R=301]
将我重定向到
http://example.com/page/1253-23098-
我需要从查询字符串中删除“1253-23098”之后的所有内容。
我在谷歌上搜索了过去 3-4 个小时,但似乎没有任何效果。 感谢任何帮助。
尝试:
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/page/?$
RewriteCond %{QUERY_STRING} ^Id=([0-9]*)-([0-9]*)-$
RewriteRule ^(.*)$ http://example.com/page/%1-%2? [L,R=301]
您可以使用:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^Id=(\d+-\d+) [NC]
RewriteRule ^page/?$ page/%1? [NC,L,R=301]