帮我改写这个htaccess的规则 [英] Help me rewrite this htaccess rule

查看:77
本文介绍了帮我改写这个htaccess的规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何重写这个规则来重定向一切回到索引或server_root中?

How do I rewrite this rule to redirect everything back to the index or server_root?

如果存在用于比如说www.site.com/articles/some-article.php一个请求,somearticle.php应重新路由回索引页。我也不想有URL显示URL的索引部分。 site.com/index是这里的一切应该是。

If there is a request for say, www.site.com/articles/some-article.php, the somearticle.php should be re-routed back to the index page. I also don't want to have the url showing the "index" portion of the URL. site.com/index is where everything should be at.

RewriteRule ^(.*)$ index.php?dk=$1 [L,QSA]


好了,现在我明白发生什么事,我认为这可以帮助别人帮助我更好。用我的规则,正是因为它是上面在我的例子,我可以没有任何问题如下回到我的index.php文件。


OK, I see now what is happening and I think it may help someone to help me better. With my rule, exactly as it is above in my example, I can get the following back into my index.php file with no problems.

http://site.com/index/somethin/else/here/test.php

下面是什么,我需要: 我需要的删除索引中的URL的一部分。这个URL应该被改写为:      http://site.com/somethin/else/here/test.php

Here is what I need: I need to remove the index portion of the url. This url should be rewritten as: http://site.com/somethin/else/here/test.php

我希望这有助于。

推荐答案

重写将通过链接直接将 www.site.com/index.php?dk=articles/some-article.php ,就是你所追求的?

The rewrite would pass the url to be www.site.com/index.php?dk=articles/some-article.php, is that what you are after?

RewriteRule ^/articles/(.*)$ index.php?dk=$1 [L,QSA]

这应该给你 www.site.com/index.php?dk=some-article.php

RewriteRule ^/articles/(.*).php$ index.php?dk=$1 [L,QSA]

为您提供 www.site.com/index.php?dk=some-article

或你想要 www.site.com/?dk=some-article

这篇关于帮我改写这个htaccess的规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆