wordpress redirect homepage with mod_rewrite
I have a Wordpress backed site and a theme that has a home page & a blog page. I want to have the domain point to the blog page with the URL in the address bar changing to http://example.com/blog
First I tried the Settings-->Reading in Wordpress and changed to a static page pointing开发者_开发百科 to blog but the URL in the address bar used only the domain http://example.com
Next I tried using mod_rewrite & mod_alias in my .htaccess file. It works to redirect the main page but when trying to preview posts and pages it doesn't work. The URLS for the preview look like so http://example.com/blog/?p=55&preview=true
Is using the RewriteMatch the best way to do this or should I be using RewriteCond & RewriteRule?
Any help would be greatly appreciated.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^$ /wp_core/index.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* /wp_core/index.php [L]
RedirectMatch 301 ^/$ http://example.com/blog/
</IfModule>
You can do everything on wordpress settings, no need to tweak your .htaccess.
On WP-Admin->Settings->Reading, you can choose an specific page for your home. If you have created already a blog page, you just select it on the drop-down menu.
In case you have problems to find the place for these setting: http://YOURDOMAIN.com/wp-admin/options-reading.php
Also, if your blog page has a different visual, you might need to set on the page a custom page-template. I can't tell you 100% what to do because it depends on how your theme is coded.
Ah, if you want to have all your pages under /blog/, you'll have to change your permalink settings as well.
精彩评论