开发者

htaccess form submit auto redirect to clean url

开发者 https://www.devze.com 2023-01-16 17:38 出处:网络
i have a site site.com/?w=thisworks site.com/w/thisalsoworksmanually i got this to work via htaccess now i have a form... when it gets submitted

i have a site

site.com/?w=thisworks
site.com/w/thisalsoworksmanually

i got this to work via htaccess

now i have a form... when it gets submitted

i get site.com/?w=stuffsubmitted i'm trying to have it auto redirect to site.开发者_开发问答com/w/stuffsubmitted

here is my htaccess that works

RewriteEngine on

RewriteRule ^w/([^/]+)/?$ /index.php?w=$1 [L]

basically..i want to auto redirect to a clean url when form gets submitted.. if you need some more clarification..please ask.


You redirect from the worng way, you redirect site.com/w/stuffsubmitted to site.com/?w=stuffsubmitted and you say that you want to redirect url with query string to that which don't have one.

RewriteCond %{query_string} w=(.*)
RewriteRule ^$ /w/%1? [R=301]


Simple solution. Don't submit form with method="GET". If you have to submit POST form, you will write manually action url.

0

精彩评论

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