GetSimple Support Forum

Full Version: htaccess - how to lose the old .html suffix for new site
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
Options -Indexes

# blocks direct access to the XML files - they hold all the data!
<Files ~ "\.xml$">
    Order allow,deny
    Deny from all
    Satisfy All
</Files>
<Files sitemap.xml>
        Order allow,deny
    Allow from all
    Satisfy All
</Files>

RewriteEngine on

# Usually it RewriteBase is just '/', but
# replace it with your subdirectory path
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule /?([A-Za-z0-9_-]+)/?$ index.php?id=$1 [QSA,L]

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!
no problem

1) admin / settings:

change
Code:
%parent%/%slug%/
to
Code:
%parent%/%slug%.html/

2) edit .htaccess:

change
Code:
RewriteRule /?([A-Za-z0-9_-]+)/?$ index.php?id=$1 [QSA,L]
to
Code:
RewriteRule /?([A-Za-z0-9_-]+).html?$ index.php?id=$1 [QSA,L]

3) delete all caches ;=)

should work
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?
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/14729...html-files

Code:
RewriteRule (.+)\.html$ /$1/ [L,R]

a simple google finds nearly everything ;=)
Connie Wrote:a simple google finds nearly everything ;=)

It sure does - but you need to understand how to use it first!

Still trying though.
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.
I am glad it works for you

Cheers, Connie