modrewrite 网站在 .htaccess 中带有斜线
我如何翻译如下 URL: http://localhost/mySite/?link=OFFERS&sublink=ARTICLE&subsublink =详细信息
至: http://localhost/mySite/OFFERS/ARTICLE/DETAIL
如果一个参数为空,它仍然应该像这样工作: localhost/mySite/?link=OFFERS&sublink=ARTICLE localhost/mySite/OFFERS/ARTICLE
额外问题:index.php 下有一个输入页面,重写应该适用于index2.php。最好的情况是它可以在本地主机和实时系统上运行而无需更改。
目前我正在使用: RewriteRule ^([^/.]+)$ index2.php?link=$1 [L] 但这只适用于一个参数,而且我很长时间都无法改进这段代码^^
How can I translate an URL like:
http://localhost/mySite/?link=OFFERS&sublink=ARTICLE&subsublink=DETAIL
to:
http://localhost/mySite/OFFERS/ARTICLE/DETAIL
if one parameter is empty it should still work like this:
localhost/mySite/?link=OFFERS&sublink=ARTICLE
localhost/mySite/OFFERS/ARTICLE
Extra problem: There is an enter page under index.php and the rewrite should work with index2.php. Best would be if it would work under localhost and on live system without changes.
Currently I'm using: RewriteRule ^([^/.]+)$ index2.php?link=$1 [L]
But that only works for one parameter and I couldn't improve this code for ages ^^
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
请注意,
localhost/mySite/OFFERS/ARTICLE
链接到localhost/mySite/?link=OFFERS&sublink=ARTICLE&sussublink=
而不是localhost/mySite/? link=OFFERS&sublink=ARTICLE
。应该不是一个大问题,但请确保 PHP 代码不会使用
isset($_GET['subsublink'])
。Note that
localhost/mySite/OFFERS/ARTICLE
links tolocalhost/mySite/?link=OFFERS&sublink=ARTICLE&sussublink=
and notlocalhost/mySite/?link=OFFERS&sublink=ARTICLE
.Should not be a big issue, but make sure the PHP code doesn't us
isset($_GET['subsublink'])
.尝试将以下内容添加到站点
mysite
目录中的 htaccess 文件中。Try adding the following to your htaccess file in the
mysite
directory of your site.