帮我重写这个htaccess规则

发布于 2024-08-23 09:04:46 字数 624 浏览 3 评论 0原文

如何重写此规则以将所有内容重定向回索引或 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

拥抱没勇气 2024-08-30 09:04:46
RewriteRule ^.*/(.*)$ /?dk=$1 [L,QSA]

...如果您只想传递文件名,或者...

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

...如果您想要完整路径

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

...if you only want to pass it the file name, or...

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

...if you want the full path

匿名。 2024-08-30 09:04:46

重写会将网址传递为 www.site.com/index.php?dk=articles/some-article.php,这就是您想要的吗?

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 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?

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

This should give you www.site.com/index.php?dk=some-article.php

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

gives you www.site.com/index.php?dk=some-article

Or do you want www.site.com/?dk=some-article ?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文