从url中删除'index.php'而不删除.htaccess中的参数

编程入门 行业动态 更新时间:2024-10-15 18:29:56
本文介绍了从url中删除'index.php'而不删除.htaccess中的参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有网址重定向条件,

www.domain/something/anotherthing/index.php

www.domain/something/anotherthing/index.php

我需要上面的网址重定向到

i need the above url to redirect to

www.domain/something/anotherthing /

www.domain/something/anotherthing/

如果我去

www.domain/index.php/something/anotherthing

www.domain/index.php/something/anotherthing

我想重定向到

www.domain/something/anotherthing

www.domain/something/anotherthing

我有一个重定向htaccess规则这个

i have a redirect htaccess rule for this

RewriteCond%{THE_REQUEST} ^ [AZ] {3,} \ s (。*)/ index.php $ 1 [NC]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s(.*)/index.php$1 [NC]

RewriteRule ^ /%1 $ 1 [R = 301,L]

RewriteRule ^ /%1$1 [R=301,L]

但这适用于第一个条件,但在后来它将我重定向到根页面。任何人都可以帮助这个重定向。

But this works for the first condition but in the later it redirect me to the root page. Can anyone please help in this redirection.

先谢谢。

推荐答案

尝试这样的事情:

RewriteBase / RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s(.*)/index.php/?([^\ \?]*) [NC] RewriteRule ^ %1/%2 [R=301,L]

这应该处理 /index.php 的任何位置。

That should handle any location of /index.php.

更多推荐

从url中删除'index.php'而不删除.htaccess中的参数

本文发布于:2023-11-01 13:29:57,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1549452.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:而不   参数   url   index   htaccess

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!