简体   繁体   中英

Drupal 7 - htaccess redirect if URL contains a certain string

How would I write a redirect rule in my htaccess file if the URL contains a certain string?

Example:

https://www.mywebsite.com/_Incapsula_Resource?SWJIYLWA=2977d8d74f63d7f8fedbea018b7a1d05&ns=2&cb=1143295674

https://www.mywebsite.com/_Incapsula_Resource?SWJIYLWA=2977d8d74f63d7f8fedbea018b7a1d05&ns=3&cb=1461264764

https://www.mywebsite.com/_Incapsula_Resource?SWJIYLWA=2977d8d74f63d7f8fedbea018b7a1d05&ns=1&cb=1693249588

If it contains _Incapsula_Resource then redirect to https://www.mywebsite.com

Any help will be greatly appreciated.

Got it. Instead of _Incapsula_Resource , use SWJIYLWA=

RewriteCond %{QUERY_STRING} SWJIYLWA=

RewriteRule .* /? [R,L]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM