The problem is,
I want to port my current website which is built upon CodeIgniter to WordPress. I do not want to hurt my google ranking and for that, I really need to map certain URLs to an existing file and for new URLs, I will let WordPress handle it in the default way. The main problem that arises is that I do not wish to change the existing domain. I want to redirect/map the files on the same domain from my existing CodeIgniter project.
Okay, let me make it a bit more clear about the state of my problem. I copied my existing CodeIgniter project into the WordPress root folder. Now, I will let the old URL being served from my CodeIgniter project and for all the new ones I will let WordPress handle it. I will also port the existing database to the new server and create a separate one for the WordPress installation.
So, how can I map my old URLs to the CodeIgniter?
My old URLs looks something like this,
http://www.example.com/site/blog/123/abc-xyz-wxy
I want to handle these URL from CodeIgniter file and the new URLs that will be created by WordPress will be handled by WordPress which would look like this,
http://www.example.com/abc-xyz-wxy
So, far this is how my .htaccess file looks like,
BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /cms/wordpress/
RewriteRule ^site/blog/([0-9]+)/([a-zA-Z0-9-]+)/?$ codeignitor/index.php/$2
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /cms/wordpress/index.php [L]
</IfModule>
END WordPress
And this thing works absolutely fine, but what I want is more of a URL masking. I want to eliminate the CodeIgnitor folder name from the URL.
For selecting the “abc-xyz-wxy” string and redirecting, try using:
Disclaimer: Never used CodeIgniter, so everyone feel free to correct.
In case anyone else happens upon this, I have a similar sounding use case where the application code resided inside
/public_html/app/
and I wanted it redirect from/public_html/
but not show theapp/
portion of it in the url. There was also an additional requirement to not route specific urls in this manner. The resulting file is below. Hopefully it helps someone on a similar journey.