复合如果那么逻辑为.htaccess

时间:2013-11-20 19:53:55

标签: .htaccess url mod-rewrite seo

我有两个索引网页,在单个域上有不同的详细信息页面。

www.mymichiganforeclosures.com/index.php 

产生:

www.mymichiganforeclosures.com/detail.php?kfld=address-city-state-zip,

www.mymichiganforeclosures.com/LandContractIndex.php

产生

www.mymichiganforeclosures.com/LandContractsDetail.php?kfld=address-city-state-zip.  

修改.htaccess页面后如下:

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]

我能够得到以下预期结果:

 www.mymichiganforeclosures.com/address-city-state-zip.html

这让我相信为了得到

相同的输出:

www.mymichiganforeclosures.com/address-city-state-zip.html

输入:

www.mymichiganforeclosures.com/LandContractsDetail.php?kfld=address-city-state-zip

我需要在我的.htaccess中使用复合重写代码块,ala:

 options -multiviews
 RewriteEngine On

 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

或者我需要弄清楚如何传递完整的通配符以获取细节和LandContractDetail(最佳)。

以下任何建议都不起作用:

 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/+LandContractDetail\.php\?kfld=([^\s&]+) [NC]
 RewriteRule ^ /%1.html? [R=301,L]
 RewriteRule ^([^.]+)\.html$ /LandContractDetail.php?kfld=$1 [L,NC,QSA]

0 个答案:

没有答案