How to redirect a URL from "example.com/search/.../?folder=something" to "example.com/something/search/.../"

StackOverflow https://stackoverflow.com/questions/22135339

문제

How to redirect a URI from example.com/search/.../?folder=something to example.com/something/search/.../?

Is there a htaccess rule?

도움이 되었습니까?

해결책

You can try this rule as your first rule:

RewriteEngine On

RewriteCond %{THE_REQUEST} \s/+([^?]+)\?folder=([^\s&]+) [NC]
RewriteRule ^ /%2/%1? [R=301,L,NE]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/(.+?)/?$ /$2/?folder=$1 [QSA,L]
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top