Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/295.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
1个mod rewrite块用于多个php页面_Php_Regex_Apache_.htaccess_Mod Rewrite - Fatal编程技术网

1个mod rewrite块用于多个php页面

1个mod rewrite块用于多个php页面,php,regex,apache,.htaccess,mod-rewrite,Php,Regex,Apache,.htaccess,Mod Rewrite,我有两个详细页面: 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

我有两个详细页面:

 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
考虑以下代码:

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

RewriteRule ^landcontracts/([^.]+)\.html$ /LandContractsDetail.php?kfld=$1 [L,NC,QSA]

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

RewriteRule ^foreclosures/([^.]+)\.html$ /detail.php?kfld=$1 [L,NC,QSA]

尝试了该代码,但得到以下错误输出。。。这就是它应该做的:但它会转到索引页…尝试多个代码块会更好吗?一个用于detail.php,另一个用于landcontractdetail.php?是的,也可以这样做。但是,在这两种情况下,什么应该是
.html
url?输出的url应该是mymichiganforeclosures.com/address-city-state-zip.html,在这两种情况下都应该是mymichiganforeclosures.com/address-city-state-zip.html-这并不重要,因为页面上有特定的措辞。。。