Rewiriting of URL in .htaccess file PHP

Hello Friends, I just want to know how can i Rewrite URL in .htaccess file

from

url=http://example.com/blogs/123/2/blog-title-goes-here

to

url=http://example.com/blogs/blog-title-goes-here

Any Help will be greatly appreciated.

Thankyou

Rewrite or Redirect? If its rewrite then try this:


RewriteEngine On
RewriteRule ^blogs/\\d+/\\d+/(.+)$ blogs/$1 [L]

This rule goes inside the .htaccess file present in the root directory of your website.

Well thanks for reply…but unforunatly its not working…sorry…(:

What does not work? What do you get?

Does it help if you do it like this:


Options +FollowSymLinks
RewriteEngine On
RewriteRule ^blogs/\\d+/\\d+/(.+)$ blogs/$1 [L]

(added 1st line)

WDH has the correct answer: Use mod_alias’ Redirect for a simple redirection. It IS important to use the correct tool for the job.

Redirect blogs/123/2/blog-title-goes-here /blogs/blog-title-goes-here 

If the blog-title-goes-here is a variable, mod_alias does utilize regex, too, but that’s native to mod_rewrite.

Regards,

DK