How can I remove the .html extension for static webpages that are indexed so they'll still work in a WordPress site?

How can I remove the .html extension for static webpages that are indexed so they'll still work in a WordPress site? - .htaccess files are extremely useful in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about html, htaccess, wordpress, search-engine-indexing, .htaccess common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your .htaccess file running smoothly.Problem :


I have a static HTML website with less than 100 pages and 99 of them are indexed in Google's search engine. I want to convert it into a WordPress website, but there are some problems I'm worried about.



My HTML website pages have an .html extension at the end of them and they're indexed with that extension, so converting those pages (even with the same content) to a WordPress page without any extension causes my whole website to be removed from Google's search.



I'm going to need to make sure that the .html extension is removed from URLs that already have just an .html extension. I want to do this using a .htaccess file. I found the following code, but it doesn't work:



^(([^/]+/)*[^/.]+).html?$

Solution :

I believe the problem is with your regular expression



This sould work fine:



RewriteEngine On
RewriteCond %REQUEST_FILENAME !-f
RewriteRule ^([^.]+)$ $1.html [NC,L]


Since I helped you with the htaccess file yesterday, I need to offer some advice here:




  1. Do not use Jaun's rule as a workaround.

  2. Leave both sites up, so the HTML based site stays indexed while you
    work on the WordPress Conversion.

  3. Sign Up for Google Webmaster Tools, and add both sites to your
    sitelist.

  4. Finish the WordPress Conversion, and remove the HTML site using the
    account you created in step 3.

  5. Create a Sitemap of the new WordPress site, and submit it to Google for Re-Indexing.

  6. Leave the permanent redirect from yesterday and the Permalink Rewrite Rules to force all your old visitors to your new site without creating Apache overkill.


Additionally, if you would like to do some further testing, give the htaccess tester tool a try. It allows you to specify a certain URL as well as the rules you would like to include and then shows which rules were tested, which ones met the criteria, and which ones were executed.

Comments

Popular posts from this blog

Rewrite in Mediawiki, remove index.php, .htaccess

.htaccess rewrite wildcard folder paths from host

Using .htaccess to set a cookie and 301 redirect