Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I've been struggling with a problem and have tried many other suggestions shown on this forum but have been unsuccessful.

I need to modify blog urls on my web site.

This is the current url:

https://www.example.com/my-blog/2021-outloook

I need the url to be this:

https://www.example.com/my-blog/entry/2021-outloook

So I'm trying to add the word "entry" to the url for the blog posts.

I've been trying to do this via htaccess without success.

Can anyone help?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
271 views
Welcome To Ask or Share your Answers For Others

1 Answer

  1. Look for this line in your .htaccess. If it doesn't exist, add it.

     RewriteEngine On
    
  2. Add this line below RewriteEngine On.

     RewriteRule ^my-blog/(.*)$ /my-blog/entry/$1 [R=301,L]
    

That will redirect your current URL as described. The R=301 makes this a permanent 301 redirect. The L directive tells Apache to stop applying any rules that follow.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...