帮我重写这个htaccess规则
如何重写此规则以将所有内容重定向回索引或 server_root?
如果有请求,例如 www.site.com/articles/some-article.php,则 somearticle.php 应重新路由回索引页面。我也不希望网址显示网址的“索引”部分。 site.com/index 是一切都应该在的地方。
RewriteRule ^(.*)$ index.php?dk=$1 [L,QSA]
好的,我现在明白发生了什么,我认为这可能会帮助别人更好地帮助我。根据我的规则,正如上面示例中的那样,我可以毫无问题地将以下内容返回到我的 index.php 文件中。
http://site.com/index/somethin/else/here/test.php
这是我需要的: 我需要删除网址的索引部分。该 url 应重写为: http://site.com/somethin/else/here/test.php
我希望这会有所帮助。
How do I rewrite this rule to redirect everything back to the index or server_root?
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]
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
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
I hope this helps.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
...如果您只想传递文件名,或者...
...如果您想要完整路径
...if you only want to pass it the file name, or...
...if you want the full path
重写会将网址传递为
www.site.com/index.php?dk=articles/some-article.php
,这就是您想要的吗?这应该给你
www.site.com/index.php?dk=some-article.php
给你
www.site.com/index.php?dk=some-article
code>还是您想要
www.site.com/?dk=some-article
?The rewrite would pass the url to be
www.site.com/index.php?dk=articles/some-article.php
, is that what you are after?This should give you
www.site.com/index.php?dk=some-article.php
gives you
www.site.com/index.php?dk=some-article
Or do you want
www.site.com/?dk=some-article
?