I have an existing site built with CodeIgniter at example.com.
I have a WordPress install at example.com/wp. Urls look like this: example.com/wp/my-page
I’m trying to figure out how I can rewrite example.com/my-page to display the contents of the example.com/wp/my-page while still displaying the URL as example.com/my-page.
CodeIgniter controls the index.php file, so I can’t use WordPress’s index.php in the root.
I’m half way there, I have it working with a plain HTML file, but getting WordPress involved rewrites the url to the /wp subdirectory.
Here’s what I’m using, in the example.com root:
<IfModule mod_rewrite.c>
RewriteEngine On
Options FollowSymLinks
RewriteBase /
RewriteRule ^my-page /wp/my-page [P]
</IfModule>
When I visit example.com/my-page I end up at example/wp.
I imagine it has something to do with the standard WordPress .htaccess in the /wp/ directory which looks like this:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wp/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wp/index.php [L]
</IfModule>
# END WordPress
I’ve tried adding the [P] flag to the WordPress rules but no luck, I also tried not setting the rewrite base to /wp/.
The problem is I don’t understand this stuff in enough detail to figure out my issue, or to know whether this is possible.
In summary, I think I’m trying to rewrite a rewritten URL without doing a redirect (hence the [P] flags).
Can this be done? Any help would be appreciated.
$ cat .htaccess
$ tree -a wp
$ cat wp/.htaccess
$ cat wp/index.php
Result:
URL visible in browser:
http://example.com/my-pageOutput:
So, if you’re still seeing a redirect after this point, that is being done by wordpress php code