Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

.htaccess file and pretty urls

  • 05-06-2011 5:59pm
    #1
    Registered Users, Registered Users 2 Posts: 99 ✭✭


    I'm currently altering a website and I was hoping to give it 'pretty urls' in order to make it better for SEO and because it looks nicer.

    The only change to the .htaccess file I wish to do is to simply remove the .html so that for example

    'www.website.ie/contactus.html' shows 'www.website.ie/contactus'.

    I've tried google to assist me but every bit of code I've put into my .htaccess file hasn't worked. Can anyone help?


Comments

  • Closed Accounts Posts: 20,759 ✭✭✭✭dlofnep


    Yugioh wrote: »
    I'm currently altering a website and I was hoping to give it 'pretty urls' in order to make it better for SEO and because it looks nicer.

    The only change to the .htaccess file I wish to do is to simply remove the .html so that for example

    'www.website.ie/contactus.html' shows 'www.website.ie/contactus'.

    I've tried google to assist me but every bit of code I've put into my .htaccess file hasn't worked. Can anyone help?

    http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html

    For anything that is going to be complex, that's the way to go.


  • Closed Accounts Posts: 20,759 ✭✭✭✭dlofnep




  • Registered Users, Registered Users 2 Posts: 1,657 ✭✭✭komodosp


    Hilarious

    I would have always just put an "index.html" file inside the contactus/ directory but yeah using a mod_rewrite probably gives a lot better flexibility.


  • Registered Users, Registered Users 2 Posts: 342 ✭✭adm


    wouldnt bother. removing .html will not help seo. only things like ? and & in url might affect seo.


  • Registered Users, Registered Users 2 Posts: 2,793 ✭✭✭oeb


    Off the top of my head, this should do it. (Make sure to test it first, this is just off the top of my head, and I have not actually tested it here first)
    <IfModule mod_rewrite.c>
        RewriteEngine On
        
        
        RewriteBase /
        
    
        RewriteCond %{REQUEST_FILENAME} !-F
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule (.*)/$ /$1.html [L,NC]
    </IfModule>
    

    That should check to see if a folder exists, and if it does not, load up /<FOLDER-NAME>.html.

    Keep in mind that you will need to modify all your calls for images, javascripts and links to use absolute URLs rather than relative ones. (IE /css/style.css rather than css/style.css)


  • Advertisement
Advertisement