开发者

Regex to escape query string otherwise simple redirect issue

开发者 https://www.devze.com 2023-02-19 10:08 出处:网络
I\'m trying to foil bots from registering on my site. The issue is a form that is on a url without a capture. I have a different form with a capture I want to redirect to

I'm trying to foil bots from registering on my site. The issue is a form that is on a url without a capture. I have a different form with a capture I want to redirect to

I want

http://site.com?task=register#content

to redirect to

http://site.com/home/register

Here is what I have so far

redirect 301 ^task\=register\#content$ http://site.com/home/register

NOTE : The solution needs开发者_JS百科 to have regex involved because the query string is complex with its characters that need escaping which the slash should be doing.

Thank you.


I would try doing it like this:

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com
RewriteRule ^(.*)$ http://www.other.com/$1 [R=permanent,L]


Remove the caret (^), i.e.

redirect 301 task\=register\#content$ http://site.com/home/register
0

精彩评论

暂无评论...
验证码 换一张
取 消