【发布时间】:2013-12-06 10:06:08
【问题描述】:
我有两个详细信息页面:
www.mymichiganforeclosures.com/detail.php?kfld=address_City_state_zip
www.mymichiganforeclosures.com/landcontractdetail.php?kfld=address_city_state_zip
我需要一个mod_rewrite参数作为参数传递php页面名称,第二个参数作为kfld查找参数传递。
以下 .htaccess 适用于 detail.php:
options -multiviews
RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+detail\.php\?kfld=([^\s&]+) [NC]
RewriteRule ^ /%1.html? [R=301,L]
RewriteRule ^([^.]+)\.html$ /detail.php?kfld=$1 [L,NC,QSA]
我想要的是:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/(*)etail\.php\?kfld=([^\s&]+) [NC]
RewriteRule ^ /%1.html? [R=301,L]
RewriteRule ^([^.]+)\.html$ /$1etail.php?kfld=$2 [L,NC,QSA]
这在 .htaccess 中可行吗?
好的!这个呢:
if foreclosures
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+detail\.php\?kfld=([^\s&]+) [NC]
RewriteRule ^ /%1.html? [R=301,L]
RewriteRule ^([^.]+)\.html$ /detail.php?kfld=$1 [L,NC,QSA]
else
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+LandContractsDetail\.php\?kfld=([^\s&]+) [NC]
RewriteRule ^ /%1.html? [R=301,L]
RewriteRule ^([^.]+)\.html$ /LandContractsDetail.php?kfld=$1 [L,NC,QSA]
endif
【问题讨论】:
标签: php regex apache .htaccess mod-rewrite