.htaccess - RewriteCond %{ENV:REDIRECT_STATUS} 200 Not Working -
i writing 301 redirect first time...
objective
i have redirect url
www.example.com/product/cat/item/product-item
www.example.com/brand/cat/item/product-item
www.example.com/cat/item/product-item
to: www.example.com/product/item
item can have values iphone-6-black-3g
(having hyphen in them)
htaccess-code
i have made test project , following in htaccess file:
rewriteengine on rewritebase /test/ rewritecond %{env:redirect_status} 200 ### have tested ^. rewriterule ^ - [l] rewriterule ^(.+)/([^\-]+)-(.+)/?$ $2/$3.php?cat=$2&item=$3 [l,r=301]
if redirect test.php?cat=$2&item=$3
showing correct values in $2
, $3
.
problem
but if redirect $2/$3.php
weird things happen.
since new url generated satisfy rule think loop occurs continue until no more match....
to break loop have added %{env:redirect_status} 200
, looks not working.
i getting crazy... solution coming head change item format apple_iphone-t
etc... having first underscore , hyphen. in way no loop
kindly suggest if can solve hyphen pattern?
you prevent loop adding conditions:
rewriteengine on rewritebase /test/ rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^(.+)/([^\-]+)-(.+)/?$ $2/$3.php?cat=$2&item=$3 [l,r=301]
the reason why %{env:redirect_status}
isn't working because using external redirect. you're redirecting browser browser sends whole new request, there's no internal redirecting condition work.
.Htaccess - Rewritecond %{Env:Redirect_Status} 200 Not Working - >>>>> Download Now
ReplyDelete>>>>> Download Full
.Htaccess - Rewritecond %{Env:Redirect_Status} 200 Not Working - >>>>> Download LINK
>>>>> Download Now
.Htaccess - Rewritecond %{Env:Redirect_Status} 200 Not Working - >>>>> Download Full
>>>>> Download LINK G5