Hi I'm just converting an old HTML site to a wordpress based site, hence all the page names have changed. When I searched for advice, it seemed that an HTML redirect in the head of each page would work - so I did that with seconds set to 0. But the old HTML pages still flash up for a couple of seconds, which looks a bit poor. So I guess I really need a 301 redirect in the .htaccess file. Can someone point me in the right direction for the right code so that every time any .HTML file is searched for in the site, it redirects to the main site index.php page. The old index.html (now replaced by index.php) is especially a problem, because browsers seem to look for the html version first, so anyone at all visiting the site gets a 2 second glimpse of the old site. Thanks for any help
Hi, I doubt that your visitors explicitely ask for http://www.example.com/index.html. They probably ask for http://www.example.com/ and your server shows the index.html page first,... because it still exists. If you remove the index.html file, this problem will disappear. Your server should directly go to index.php. Regarding the other pages, if you think it is important to redirect the visitors, there are many web pages that explain how to do a 301 redirect, but it can get more tricky in the WordPress environment. Jean-Luc
Thanks, 301 it is then... Jean-Luc, I had looked at your site earlier thanks. My htaccess skills are non-existent so if I don't know the exact code for my circmstances I am nervous about trying it... If I take as my starting point your suggestion: RedirectPermanent /old-file-name.html http://www.new-domain.com/new-directory/new-file-name.html I have about 70 pages - do I have to do this separately for every page or is there a 'wildcard' so I can say something like RedirectPermanent /*.html http://www.new-domain.com/index.php All old files were html, now there are no html files, and I am happy if they all redirect to the new home page rather than to specific pages in the new site. Cheers
I would try this .htaccess : Options +FollowSymlinks RewriteEngine on RewriteRule ^.*\.html$ / [R=301] Code (markup): If the .htaccess file already exists, add the lines in the file (not tested). Jean-Luc
That doesn't seem to work - it tries to find the file file.html in the new version and tells me 'Sorry, no posts matched your criteria.' I only added the line RewriteRule ^.*\.html$ / [R=301] because the other two lines are already in the file (for the http:// to www redirect) - should I add them again? Overall at the moment I have RewriteEngine on Options +FollowSymLinks RewriteCond %{HTTP_HOST} ^sitename\.com$ [NC] RewriteRule ^(.*)$ http://www.sitename.com/$1 [R=301,L] RewriteRule ^.*\.html$ / [R=301] plus a few lines wordpress has added
This should work better : RewriteEngine on Options +FollowSymLinks RewriteCond %{HTTP_HOST} ^sitename\.com$ [NC] RewriteRule ^(.*)$ http://www.sitename.com/$1 [R=301,L] RewriteRule ^.*\.html$ http://www.sitename.com/ [R=301,L] ... WordPress stuff ... Code (markup): Jean-Luc
Seems to work perfectly Do I still need to clear all the contents out of the old HTML files to avoid any risk of a duplicate content penalty or is that a waste of time now? Thanks again for your help