只需使用 .htaccess 删除一个 url 段 [英] Simply remove a url segment with .htaccess

查看:28
本文介绍了只需使用 .htaccess 删除一个 url 段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想获取这个网址:

I am simply trying to get this URL:

http://foo.com/entry/random-entry-123

重定向到:

http://foo.com/random-entry-123

random-entry-123"是动态的.
每个条目都不同.非常感谢您对此的任何帮助!

The "random-entry-123" is dynamic.
Different for each entry. Any help with this is greatly appreciated!

推荐答案

假设没有使用进一步的重写,并且 /entry/ 中的所有链接都将被重写,那么试试这个:

Assuming no further rewrites are in use, and all links inside /entry/ are to rewritten, then try this:

RewriteEngine on
RewriteBase /

RewriteRule ^/entry/(.+)$ /$1 [L,QSA]

如果文件中有进一步的重写,则丢失 [L].

Lose the [L] if there are further rewrites ahead in the file.

这篇关于只需使用 .htaccess 删除一个 url 段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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