简体   繁体   English

搜索表格Htaccess重写

[英]Search Form Htaccess rewrite

i have a htaccess rules that are not working well, it looks like its not assuming almost all of them, if i put only one rule it works fine, the problem is when i insert all of them, here is my code above. 我有一个无法正常运行的htaccess规则,似乎它没有假设几乎所有规则,如果我只放一个规则,它就可以正常工作,问题是当我插入所有规则时,这是上面的代码。

# Search Form Url Result
#search by category
RewriteRule ^jobs/([^/\.]+)$ jobs.php?Category=$1

#search by location
RewriteRule ^jobs/([^/\.]+)$ jobs.php?Location=$1

#search by category and location
RewriteRule ^jobs/([^/\.]+)/([^/\.]+)$ jobs.php?Category=$1&Location=$2

Basically each rule is for each situation, for example if the user search only for category or location, or even search for category and location. 基本上,每个规则都是针对每种情况的,例如,如果用户仅搜索类别或位置,甚至搜索类别和位置,那么这些规则都适用。

You Rule1 and Rule2 are using same pattern ie ^jobs/([^/\\.]+)$ so only 1st will work. 您的Rule1Rule2使用相同的模式,即^jobs/([^/\\.]+)$因此只有1st有效。

You have to add an appropriate identifier after /jobs/ to distinguish between category and location URIs. 您必须在/jobs/之后添加一个适当的标识符,以区分类别和位置URI。

You may consider: 您可以考虑:

# Search Form Url Result

#search by category
RewriteRule ^jobs/c/([^/.]+)/?$ jobs.php?Category=$1 [L,QSA]

#search by location
RewriteRule ^jobs/l/([^/.]+)/?$ jobs.php?Location=$1 [L,QSA]

#search by category and location
RewriteRule ^jobs/([^/.]+)/([^/.]+)/?$ jobs.php?Category=$1&Location=$2 [L,QSA]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM