.htaccess中的Regex-删除特定单词



是否可以删除以下url中的shop-single?id=http://example.com/shop-single?id=test

我尝试了以下内容,我在另一篇文章中读到了,但不幸的是没有奏效:

RewriteRule ^(.*)shop-single?id=(.*)$ http://%{SERVER_NAME}/$1-$2 [NC,R=301,L]

在做这件事之前,我要删除像这样的.html(有效(:

RewriteCond %{THE_REQUEST} /([^.]+).html [NC]
RewriteRule ^ /%1 [NC,L,R]
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^ %{REQUEST_URI}.html [NC,L]

这样做:

Options -Indexes -MultiViews +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(?:www.)?jiphalk361.361.axc.nl$ [NC]
RewriteRule ^ http://www.1912websites.nl%{REQUEST_URI} [R=301,L]
# external redirect from actual URL to pretty one
RewriteCond %{THE_REQUEST} s/+shop-single?id=([^s&]+)s [NC]
RewriteRule ^ /%1? [R=302,L,NE]
RewriteCond %{THE_REQUEST} s/+([^.]+).html [NC]
RewriteRule ^ /%1 [NE,L,R]
# internal forward from pretty URL to actual one
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^.]+?)/?$ shop-single.html?id=$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1.html -f
RewriteRule ^(.+?)/?$ $1.html [L]

最新更新