开发者

Remove part of a URL

开发者 https://www.devze.com 2023-03-01 03:16 出处:网络
How can I remove main/ in http://domain/main/about 开发者_高级运维 so the URL will be like this http://domain/about

How can I remove main/ in http://domain/main/about

开发者_高级运维

so the URL will be like this http://domain/about

Thanks


Well, in the absence of any further details, you could try something like this:

RewriteRule (.*)/main/(.*) $1/$2

But this is a VERY broad rule - you'd probably want to tune it more tightly than that. Try turning the RewriteLogLevel to 9 and watching the rules as they get processed so you can get a better idea of what is being matched.


If you only need one file to be rewritten :

RewriteRule main/about about [L]

or else the TML answer is good :

RewriteRule (.*)/main/(.*) $1/$2 [L]

It rewrites any URL with a /main (even in third, fourth, ... places) in it to prefix/suffix URL.

0

精彩评论

暂无评论...
验证码 换一张
取 消