需要在.htaccess中重写URL吗?

时间:2014-03-26 07:56:38

标签: php apache .htaccess mod-rewrite

我需要从你的帮助中重写下面的网址。

我有这个搜索网址

search-job.php?category=Accountancy&emp_type=Long+Term&working_pattern=Full+Time&location=Algeria&search=Search+Job

search-job-in-Accountancy-for-Full+Time-in-Algeria.html

或者来自

search-job.php?category=2&emp_type=2&working_pattern=2&location=12&search=Search+Job

到此

search-job-2-2-2-12.html

我已经完成了这个

job-detail.php?j=Exalture-Software-Labs-Pvt-Ltd-Application-Developer-Websphere-Commerce-Suite-ais-GBS-in-India-Full-Time-Mumbai-11.html

到此

job-detail/Exalture-Software-Labs-Pvt-Ltd-Application-Developer-Websphere-Commerce-Suite-ais-GBS-in-India-Full-Time-Mumbai-11.html

我的.htaccess低于

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /temp

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+job-detail\.php\?j=([^\s&]+) [NC]
RewriteRule ^ job-detail/%1? [R=301,L]

RewriteRule ^job-detail/([^/]+)/?$ job-detail.php?j=$1 [L,QSA]

请提供一些帮助。

1 个答案:

答案 0 :(得分:2)

您需要以下附加规则:

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+search-job\.php\?category=([^&]*)&emp_type=([^&]*)&working_pattern=([^&]*)&location=([^&]*)&search=([^\s&]+) [NC]
RewriteRule ^ search-job-%1-%2-%3-%4? [R=301,L,NE]

RewriteRule ^search-job-([^-]*)-([^-]*)-([^-]*)-([^-]*) search-job.php?category=$1&emp_type=$2&working_pattern=$3&location=$4&search=Search+Job [L,QSA]