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:
http://example.com/folder1/folder2/page.php
Now I want to rewrite the url to (for example)
http://example.com/testing/folder2/page.php
The
folder1
is an existing url. How can I change it totesting
?The following I found “somewhere in the internet”:
<IfModule mod_alias.c> RedirectMatch 301 /testing/folder2/(.*) /folder1/folder2/$1 </IfModule>
I need it as a PHP function to use it in WordPress.
Answer
You can do rewrites in wordpress by using the add_rewrite_rule()
function.
Please see:
https://codex.wordpress.org/Rewrite_API/add_rewrite_rule
Attribution
Source : Link , Question Author : papa.ramu , Answer Author : heady12