开发者

Can I change words in a URL served by an Apache server?

开发者 https://www.devze.com 2023-03-28 01:21 出处:网络
I have a url that looks something like: http://host.name.com/old/ and I want the new URL to be http://host.name.com/new/.

I have a url that looks something like: http://host.name.com/old/ and I want the new URL to be http://host.name.com/new/.

Is this easily done in Apac开发者_如何学运维he? I can't modify every link that has /old/ and I need the webserver to do this for me automatically.


This is a perfect task for mod_rewrite. Especially see Redirecting and Remapping with mod_rewrite).

RewriteEngine On
RewriteRule ^/old/$ /new/ [PT]

(not tested, wasn't clear if you need internal or external URL rewriting, may cause temporary blindess and abdominal distension, etc.)

0

精彩评论

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