Permalinks not working but mod_rewrite & htaccess IS working
-
I have a Zend Framework site in this dir
/var/www/example.com/
and put the WP blog in this dir/var/www/example.com/public/blog/
The following are the important files…
/var/www/example.com/public/.htaccess
contains:RewriteEngine on RewriteBase / RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*$ - [NC,L] RewriteRule ^blog - [NC,L] #Just added this line, it was previous not there RewriteRule ^.*$ index.php [NC,L]
Then my
.htaccess
in the/blog/
folder is this:# BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase /blog/ RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /blog/index.php [L] </IfModule> # END WordPress
Clicking around the zend site works fine & the rewrite removing index.php from the URL is perfect. Going into the /blog/ subfolder loads the WP blog just fine. But when I click on any post in the blog, it gets redirected to the ZF app, and doesn’t stay within wordpress.
The end result I am chasing is to keep the two separate, yet make sure both of them rewrite the index.php so it isn’t rendered in the URL.
I don’t have good experience with htaccess so I am not sure what’s happening. Here is my VHost just for good measure.
<VirtualHost *:80> ServerAdmin webmaster@dummy-host2.example.com DocumentRoot "/var/www/example.com/public" ServerName example.com ErrorLog "logs/example.local-error.log" CustomLog "logs/example.local-access.log" common <Directory "/var/www/example.com/public" > Options Indexes FollowSymLinks AllowOverride All Order allow,deny allow from all </Directory> <Location /> RewriteEngine on RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule !\.(js|ico|gif|jpg|png|css)$ /index.php </Location> SetEnv APPLICATION_ENV development </VirtualHost>
NOTE I removed the .htaccess in the
/public/
folder for testing because of the Rewrite rule in the VHost, but my problem remains.The request & response URLs are the same as they are shown in the browser:
http://example.local/blog/my-test-blog-post/
HOWEVER, the browser renders an error from ZF, indicating it was directed to the
public/index.php
file instead of the intendedpublic/blog/index.php
file. I also used Netbeans & XDebug to step through the code. I put a breakpoint on the first line of both index.php files, and when clicking a blog post link, it immediately loads the ZF index.php, not the /blog/index.phpIt appears if I use a URL like
http://example.local/blog/?p=695
it works and is not routed to the ZF app. but when I use custom permalinks in wp-admin likehttp://example.local/blog/my-test-blog-post/
it tries to route to ZF.Options FollowSymLinks
&AllowOverride All
are both set and verify this because the URL rewrite is successful throughout the ZF app. I just can’t get it right…As a final note, this permalink works on WP:
/index.php/%post_id%/%postname%/
But I want to use this without the index file:
/%post_id%/%postname%/
- The topic ‘Permalinks not working but mod_rewrite & htaccess IS working’ is closed to new replies.