如何使用HTACCESS的查询字符串重定向页面?

时间:2018-07-24 23:33:18

标签: php apache redirect query-string url-redirection

如何使用查询字符串重定向以下URL。结果,新的URLS将包含"page = page name"作为第一个参数。其他所有参数的值都会变化。

1)

OLD

  

https://example.com/index.php?LOANAMOUNT=350%2C000.00&DOWNPAYMENT=20.000+&DOWNPAYMENT_TYPE=Percent&TERM=30&TERM_UNITS=Years&INTERESTRATE=5.700+&COMPUTE=COMPUTE&CALCULATORID=HF02&TEMPLATE_ID=www.abc.com_1&PostBack=true#results

  

https://example.com/index.php?page=monthly-payment&LOANAMOUNT=350%2C000.00&DOWNPAYMENT=20.000+&DOWNPAYMENT_TYPE=Percent&TERM=30&TERM_UNITS=Years&INTERESTRATE=5.700+&COMPUTE=COMPUTE&CALCULATORID=HF02&TEMPLATE_ID=www.abc.com_1&PostBack=true#results

2)

OLD

  

https://example.com/index.php?MAXPAYMENTAMOUNT=2%2C100.00&INSURANCE=80.00&PROPERTYTAX=1.250+&PROPERTYTAX_TYPE=Percent&ASSOCIATIONDUES=0.00&DOWNPAYMENT=10.000+&DOWNPAYMENT_TYPE=Percent&TERM=30&TERM_UNITS=Years&INTERESTRATE=5.700+&INCOMETAXRATE=25.000+&COMPUTE=COMPUTE&CALCULATORID=HF09&TEMPLATE_ID=www.abc.com_1&PostBack=true#results

  

https://example.com/index.php?page=how-much-can-i-afford&MAXPAYMENTAMOUNT=2%2C100.00&INSURANCE=80.00&PROPERTYTAX=1.250+&PROPERTYTAX_TYPE=Percent&ASSOCIATIONDUES=0.00&DOWNPAYMENT=10.000+&DOWNPAYMENT_TYPE=Percent&TERM=30&TERM_UNITS=Years&INTERESTRATE=5.700+&INCOMETAXRATE=25.000+&COMPUTE=COMPUTE&CALCULATORID=HF09&TEMPLATE_ID=www.abc.com_1&PostBack=true#results

3)

OLD

  

https://example.com/index.php?ORIGINALLOANAMOUNT=400%2C000.00&ORIGINALTERM=30&ORIGINALTERM_UNITS=Years&LOANSTARTMONTH=7&LOANSTARTYEAR=2018&CURRENTRATE=5.700+&CASHOUT=5%2C000.00&NEWRATE=5.250+&POINTS=1.000+&OTHERFEES=1%2C500.00&NEWTERM=30&NEWTERM_UNITS=Years&TAXRATE=28.000+&RATEOFRETURN=2.300+&BALLOONTERM=15&BALLOONTERM_UNITS=Years&COMPUTE=COMPUTE&CURRENTCOMPOUNDING=6&NEWCOMPOUNDING=6&CALCULATORID=HF01&TEMPLATE_ID=www.abc.com_1&PostBack=true#results

  

https://example.com/index.php?page=should-i-refinance&ORIGINALLOANAMOUNT=400%2C000.00&ORIGINALTERM=30&ORIGINALTERM_UNITS=Years&LOANSTARTMONTH=7&LOANSTARTYEAR=2018&CURRENTRATE=5.700+&CASHOUT=5%2C000.00&NEWRATE=5.250+&POINTS=1.000+&OTHERFEES=1%2C500.00&NEWTERM=30&NEWTERM_UNITS=Years&TAXRATE=28.000+&RATEOFRETURN=2.300+&BALLOONTERM=15&BALLOONTERM_UNITS=Years&COMPUTE=COMPUTE&CURRENTCOMPOUNDING=6&NEWCOMPOUNDING=6&CALCULATORID=HF01&TEMPLATE_ID=www.abc.com_1&PostBack=true#results

1 个答案:

答案 0 :(得分:0)

  • 在您的Web服务器上创建一个.htaccess文件

重定向URL

在.htaccess文件中使用重定向,使您可以将用户从旧页面重定向到新页面,而不必保留旧页面。例如,如果使用index.html作为索引文件,然后将index.html重命名为home.html,则可以设置重定向以将用户从index.html发送到home.html。

例如:

重定向到本地站点文件

Redirect /path/to/old/file/old.html /path/to/new/file/new.html

重定向到外部站点文件

Redirect /path/to/old/file/old.html http://www.example.com/new/file/new.html

重定向示例

从index.html文件重定向到其他目录

Redirect /index.html /new/

从index.html重定向到default.html

Redirect /index.html /default.html

将本地/ private目录重定向到另一个站点的私有目录

Redirect /private/ http://www.example.com/private/

引用:https://help.dreamhost.com/hc/en-us/articles/215747748-How-can-I-redirect-and-rewrite-my-URLs-with-an-htaccess-file-