表单提交错误与htaccess的规则 [英] Form submission error with htaccess rules
问题描述
我对主页的index.php这之后提交的URL看起来将变量传递到页面的search.php形式 justdlal.com/search/Computer-Hardware/Delhi
在同一页我有相同的形式有两个输入城市和关键字,但在提交后,一定要到URL如
justdlal.com/search/laptop/Delhi
但相反,它是附加的搜索查询到当前的URL像
justdlal.com/search/Computer-Hardware/search.php?keyword=laptop&city=Delhi
我的htaccess code
RewriteEngine叙述上
的RewriteBase /
重写规则^(搜索)/([^ +] *)\ + +([^ +] * \ + *)$/ $ 1 / $ 2- $ 3 [L,NC]
重写规则^(搜索)/([^ +] *)\ +([^ +] *)$/ $ 1 / $ 2- $ 3 [L,R = 301,NE,NC]
的RewriteCond%{THE_REQUEST} \ S / +搜索\ .PHP \关键字=([^&安培] +)?&安培;城市=([^ \ S&功放;] +)[NC]
重写规则^ /搜索/ 1%/ 2%? [R = 301,L,NE]
重写规则^搜索/([\ w - ] +)/([\ w - ] +)?/ $ /search.php?keyword=$1&city=$2 [L,QSA]
请尝试以下规则:
RewriteEngine叙述上
的RewriteBase /
重写规则^(搜索)/([^ +] *)\ + +([^ +] * \ + *)$/ $ 1 / $ 2- $ 3 [L,NC]
重写规则^(搜索)/([^ +] *)\ +([^ +] *)$/ $ 1 / $ 2- $ 3 [L,R = 301,NE,NC]
的RewriteCond%{} THE_REQUEST /search\.php\?keyword=([^&]+)&city=([^\s&]+)[NC]
重写规则^ /搜索/ 1%/ 2%? [R = 301,L,NE]
重写规则^搜索/([\ w - ] +)/([\ w - ] +)?/ $ /search.php?keyword=$1&city=$2 [L,QSA]
I have form on home page index.php which passes variables to page search.php after submission url looks like justdlal.com/search/Computer-Hardware/Delhi
In the same page i have same form with two inputs city and keyword but after submitting it must go to url like
justdlal.com/search/laptop/Delhi
but instead it is appending search query to current url like
justdlal.com/search/Computer-Hardware/search.php?keyword=laptop&city=Delhi
My htaccess code
RewriteEngine on
RewriteBase /
RewriteRule "^(search)/([^+]*)\++([^+]*\+.*)$" /$1/$2-$3 [L,NC]
RewriteRule "^(search)/([^+]*)\+([^+]*)$" /$1/$2-$3 [L,R=301,NE,NC]
RewriteCond %{THE_REQUEST} \s/+search\.php\?keyword=([^&]+)&city=([^\s&]+) [NC]
RewriteRule ^ /search/%1/%2? [R=301,L,NE]
RewriteRule ^search/([\w-]+)/([\w-]+)/?$ /search.php?keyword=$1&city=$2 [L,QSA]
Try these rules:
RewriteEngine on
RewriteBase /
RewriteRule "^(search)/([^+]*)\++([^+]*\+.*)$" /$1/$2-$3 [L,NC]
RewriteRule "^(search)/([^+]*)\+([^+]*)$" /$1/$2-$3 [L,R=301,NE,NC]
RewriteCond %{THE_REQUEST} /search\.php\?keyword=([^&]+)&city=([^\s&]+) [NC]
RewriteRule ^ /search/%1/%2? [R=301,L,NE]
RewriteRule ^search/([\w-]+)/([\w-]+)/?$ /search.php?keyword=$1&city=$2 [L,QSA]
这篇关于表单提交错误与htaccess的规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!