0
votes

I have CodeIgniter at localhost/site and Wordpress in a subdirectory at localhost/site/blog.

Each is working fine - except I want certain urls in the site directory to point to the Wordpress subdirectory.

I'm forwarding them in the site folder's .htaccess like so (I'm a rewrite noob):

RewriteEngine On

RedirectMatch Permanent ^/site/about/? /site/blog/about

# Do not enable rewriting for files or directories that exist
RewriteCond $1 !(^site/blog/)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# For reuests that are not actual files or directories,
# Rewrite to index.php/URL
RewriteRule ^(.*)$ index.php/$1 [PT,L]

The problem is that localhost/site/about/ always forwards to localhost/site/blog/about/ and changes the address bar. I need the page at localhost/site/blog/about/ to be served up when a user visits localhost/site/about.

In order to view the page at localhost/site/blog/about/, I had to add the RewriteBase directive and alter the RewriteRule in the following .htaccess in the blog subdirectory:

RewriteEngine On
RewriteBase /site/blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /site/blog/index.php [L]

Without this addition, the page at localhost/site/blog/about shows the CodeIgniter 404 error page. (The RewriteBase actually seems to have no effect).

Eventually, the site will be hosted at www.site.com and the Wordpress installation will be at www.site.com/blog.

I've tried a bunch of different solutions and nothing has worked. Any help is appreciated.

1

1 Answers

0
votes

The reason site/about/ always forwards to site/blog/about/ is because you have told it to with: RedirectMatch Permanent ^/site/about/? /site/blog/about
To have site/about/ stay in the URL bar, but show the content from site/blog/about/ the following should do it:

RewriteEngine On
RewriteRule ^site/about/$ /site/blog/about/ [L]