【发布时间】:2012-02-16 03:36:52
【问题描述】:
如何翻译如下网址: http://localhost/mySite/?link=OFFERS&sublink=ARTICLE&subsublink=DETAIL
到: http://localhost/mySite/OFFERS/ARTICLE/DETAIL
如果一个参数是空的,它应该仍然像这样工作: localhost/mySite/?link=OFFERS&sublink=ARTICLE 本地主机/mySite/OFFERS/ARTICLE
额外问题:index.php 下有一个进入页面,重写应该与 index2.php 一起工作。最好是它可以在 localhost 和实时系统上运行而无需更改。
目前我正在使用:RewriteRule ^([^/.]+)$ index2.php?link=$1 [L] 但这仅适用于一个参数,我无法改进这段代码多年^^
【问题讨论】:
-
进入页面是什么意思?你的意思是进入站点/离开站点?
-
只是重定向不适用于 index.php -> 不仅适用于 /?link=asdf。但是对于 /index2.php?link=asdf index.php 只是一个带有一些内部链接的欢迎页面
-
我还是不明白。您的意思是要将
index.php/?link=asdf或/?link=asdf重定向到/index2.php?link=asdf吗? -
使用 modrewrite 可以重定向到一个站点并以可识别的方式提供该站点参数。这里的目标站点应该是index2.php。通常它是从 localhost/mysite/link 到 localhost/mysite/?link=asdf 的重定向。但我希望它到 localhost/mysite/index2.php?link=asdf。希望对您有所帮助...
标签: .htaccess mod-rewrite slash