how to rewrite folder name in url to another name

I am wondering wether it’s possible to use Apaches .htaccess to rewrite a folder name – using a WordPress function.

Lets say I have a url like:

Now I want to rewrite the url to (for example)

The folder1 is an existing url. How can I change it to testing?

The following I found “somewhere in the internet”:

<IfModule mod_alias.c>
    RedirectMatch 301 /testing/folder2/(.*) /folder1/folder2/$1

I need it as a PHP function to use it in WordPress.


You can do rewrites in wordpress by using the add_rewrite_rule() function.

Please see:

Source : Link , Question Author : papa.ramu , Answer Author : heady12

Leave a Comment