Since installing a wordpress blog on my site I have this problem. I want to redirect all pages like http://linklister.co.uk/blog/ to http://www.linklister.co.uk/blog/. I have tried a few different 301 redirects but none of them have worked. If necessary I will pay somebody to sort this out for me. Here's the htaccess code as it is with no redirect. ################################################# ## PHP Link Directory - Apache Server Settings ## ################################################# # Prevent .htaccess and .htpasswd files from being viewed by web clients <Files "^\.ht"> Order allow,deny Deny from all </Files> # Protect files <Files ~ "^(.*)\.(inc|inc\.php|tpl|sql)$"> Order deny,allow Deny from all </Files> # Protect directories <Files ~ "^(backup|files|images|include|lang|libs(/.+)?|temp(/.+)?|templates(/.+)?|javascripts(/.+)?)$"> Order deny,allow Deny from all </Files> # Disable directory browsing Options -Indexes # Follow symbolic links in this directory Options +FollowSymLinks # Override PHP settings that cannot be changed at runtime # (If your server supports PHP settings via htaccess you can comment following two lines off) # php_value register_globals 0 # php_value session.auto_start 0 # Customized error messages # ( If you are running in a subfolder please add it, example: "directory/index.php?httpstatus=404" ) ErrorDocument 404 index.php?httpstatus=404 # Set the default handler DirectoryIndex index.php # URL rewrite rules <IfModule mod_rewrite.c> RewriteEngine On ## A-Z Links Rewrite## RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-l RewriteRule (.*)alpha-(.*)/ index.php?letter=$2 [QSA,NC] ## Pagerank Stats Rewrite## RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-l RewriteRule (.*)livepagerank-(.*)/ index.php?pr=$2 [QSA,NC] ## Details Link Page Rewrite## RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-l RewriteRule (.*)detail/link-(.*).htm[l]?$ detail.php [QSA,NC] ## Pagination Rewrite RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-l RewriteRule (.*)page-(\d+)\.htm[l]?(.*)$ $1/?p=$2 [PT,NC] ## Category redirect RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-l RewriteRule ^(.*)$ index.php [QSA,L] </IfModule> Code (markup): TIA, Steve
i have done the same thing recently, i copyed the blog from it's home on /blog to a different site, this will also redirect all the arictles to the same url on the new host, just modify for yourself (these need to go at top of the file of the old location) ### BLOG REDIRECT RewriteRule ^blog([/]?)$ http://www.sitearmoryblog.com/ [L,R=301] RewriteRule ^blog/([0-9a-zA-Z/\_\-]+)$ http://www.sitearmoryblog.com/$1 [L,R=301]
Thanks cyanide that has worked for the main site, problem now is when I navigate to the blog the links just lead back to the main site. I think I need to change the htaccess in the blog, this is the code: # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase /blog/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /blog/index.php [L] </IfModule> # END WordPress Code (markup):
Forgive me if this has been stated and tried. But I didn't see it in your .htaccess file. In your root .htaccess file at the top. Put Best of luck.
That has worked fine for me before and still does phpld and wordpress sites ex: http://directorymix.com and http://directorymix.com/blog
For those who were interested in the fix, I removed the wordpress .htaccess and placed the following into the root .htaccess: # Custom: Ensure www is used RewriteCond %{HTTP_HOST} ^linklister.co.uk [NC] RewriteRule ^(.*)$ http://www.linklister.co.uk/$1 [L,R=301] # Custom: Blog RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^blog/(.*)$ /blog/index.php [L] Code (markup): Pretty much what people had suggested.