views:

667

answers:

1

Hello All

I have started a site up using html only, switched it over to php to make my life easier and have used the following code in the .htaccess to ensure all users (who may have bookmarked) are still seeing the right pages:

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.+)\.html$ http://domain.com/$1.php [R,NC]

Now I am working on the news section a wordpress blog (inside a /news directory) that would be lovely to use permalinks with, when I slap the rewrite code below into my .htaccess all my files outside of the wordpress directory default to wordpresses 404, they still have the correct address in the bar, but no information.

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /news/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /news/index.php [L]
</IfModule>

Can anyone help on the correct structure for the .htaccess - I tend to use snippets for specific tasks rather than write htaccess stuff.

Thanks

+1  A: 

Your rules have to be come before the Wordpress rules and you need to add an [L] to your RewriteRule:

RewriteRule ^(.+)\.html$ http://domain.com/$1.php [R,NC,L]

Which will tell .htaccess to stop processing rules.

I would recommend a permanent (301) redirect so Google and the other search engines will update their listings:

RewriteRule ^(.+)\.html$ http://domain.com/$1.php [R=301,NC,L]
Doug Neiner
Thanks that works perfectly
Lawrence
@Lawrence! Happy to help! Be sure to mark the answer as correct as it will give us both rep, and you more credibility the next time you ask a question! Good luck with your project.
Doug Neiner