表单提交错误与htaccess的规则表单、规则、错误、htaccess

2023-09-02 00:56:39 作者:咽下泪水你就是女王

我对主页的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]
 
jsp中表单提交的问题

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]