How to rewrite a folder name using .htaccess?

Find best Web Development tips and Tricks.
Post Reply
Posts: 10
Joined: Thu Jun 23, 2016 10:08 am
Location: India

How to rewrite a folder name using .htaccess?

Post by apurba_soft » Thu Jun 23, 2016 11:43 am

Hi, I'm not good in .htaccess.

I have some links which are indexed by google and I don't want to loose those, so I want to redirect those links to a new folder name using .htaccess

Old link:

I want:

Please advice me guys.

Site Admin
Posts: 95
Joined: Wed Jun 22, 2016 1:28 pm
Location: India

Re: How to rewrite a folder name using .htaccess?

Post by arnlweb » Thu Jun 23, 2016 11:47 am

Ok, simply you can try this.

Code: Select all

RewriteEngine on
RewriteRule ^dl/(.*) songs/$1
mod_rewrite can only rewrite/redirect requested URIs.
So you would need to request /songs/… to get it rewritten to a corresponding /dl/

Alternate tips:

Code: Select all

RewriteCond %{THE_REQUEST} ^GET\ /songs/
RewriteRule ^songs/(.*) /dl/$1 [L,R=301]
Hope, It helps you.

Post Reply