The following warnings occurred: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Warning [2] Undefined array key "allowautourl" - Line: 584 - File: inc/class_parser.php PHP 8.1.31 (Linux)
|
htaccess - how to lose the old .html suffix for new site - Printable Version +- GetSimple Support Forum (http://get-simple.info/forums) +-- Forum: GetSimple (http://get-simple.info/forums/forumdisplay.php?fid=3) +--- Forum: General Questions and Problems (http://get-simple.info/forums/forumdisplay.php?fid=16) +--- Thread: htaccess - how to lose the old .html suffix for new site (/showthread.php?tid=3446) |
htaccess - how to lose the old .html suffix for new site - thedoglett - 2012-08-17 Just wondering if any of you chaps could help out with a htaccess problem I'm having? I'm not too hot on htaccess rules so any help would be appreciated. I'm moving a customer from a static html site over to Get Simple and I want to make sure that the changeover doesn't affect his seo rankings which are pretty darn good. At the moment a link to a page on his site looks like this: Code: www.his-site.com/a-page-title-here.html Get Simple now displays links like this (which is exactly what I want): Code: www.his-site.com/a-page-title-here I have the default htaccess file which is as follows: Code: AddDefaultCharset UTF-8 What would I need to add/change so that anyone who clicks on an old link from a search engine (which has .html at the end of it) will be taken to the dynamic non-.html version without throwing up an error 404 page? I don't want to change all the pages on the site to include the .html suffix via htaccess and the custom slug option, just redirect any requests for a page ending with .html to the non-.html page. Hope that makes sense - any help would be appreciated as htaccess always blows my mind! htaccess - how to lose the old .html suffix for new site - Connie - 2012-08-17 no problem 1) admin / settings: change Code: %parent%/%slug%/ Code: %parent%/%slug%.html/ 2) edit .htaccess: change Code: RewriteRule /?([A-Za-z0-9_-]+)/?$ index.php?id=$1 [QSA,L] Code: RewriteRule /?([A-Za-z0-9_-]+).html?$ index.php?id=$1 [QSA,L] 3) delete all caches ;=) should work htaccess - how to lose the old .html suffix for new site - thedoglett - 2012-08-17 Thanks for the quick reply Connie! I think the above is for adding a .html suffix to all the pages though. What I'm trying to do is get any old links from search engines which point to a .html page to automatically display the page without the .html suffix. An example: at the moment the client has a page called "about-us.html" but the Get Simple site displays this page as "about-us". This means that anyone going to the .html page gets a 404 error. I don't really want to add the .html suffix to all of his existing pages, just put in a rule which says "you're looking for a .html page, I'll show you a page with the same url just without the .html bit". Is this possible? htaccess - how to lose the old .html suffix for new site - Connie - 2012-08-17 if you do not want to continue with .html-suffixes, you have to write a REDIRECT-Rule you can generate this rule online and add it to your .htaccess see here: http://stackoverflow.com/questions/1472982/htaccess-redirect-all-html-files Code: RewriteRule (.+)\.html$ /$1/ [L,R] a simple google finds nearly everything ;=) htaccess - how to lose the old .html suffix for new site - thedoglett - 2012-08-17 Connie Wrote:a simple google finds nearly everything ;=) It sure does - but you need to understand how to use it first! Still trying though. htaccess - how to lose the old .html suffix for new site - thedoglett - 2012-08-17 Solved. Code: RewriteRule (.+)\.html$ http://www.website-address-goes-here.com/$1/ [R=301,NC] This goes before the last rule in the htaccess file: Code: RewriteRule /?([A-Za-z0-9_-]+)/?$ index.php?id=$1 [QSA,L] Thanks for the pointers folks. htaccess - how to lose the old .html suffix for new site - Connie - 2012-08-18 I am glad it works for you Cheers, Connie |