1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

htaccess /file.html -> /file

Discussion in 'Apache' started by Helado, Oct 17, 2010.

  1. #1
    Hi,

    I am uploading HTML files to my webserver, for example file.html. This page is accessed through www.site.com/file.html - I want it as www.site.com/file without the .html. Well, I've got the code for that which is as follows...

    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}\.html -f
    RewriteRule ^(.*)$ $1.html
    
    Code (markup):
    So if I go to www.site.com/file it shows the page. However, I now have to URLs: /file.html and /file - if Google sees both of these it will think it's a duplicate page, so how do I sort this? I tried making file.html redirect to file, but that causes a looping error. I just want the page/file to be accessible via www.site.com/file and NOT www.site.com/file.html

    Would appreciate some help.
     
    Helado, Oct 17, 2010 IP
  2. kmap

    kmap Well-Known Member

    Messages:
    2,215
    Likes Received:
    29
    Best Answers:
    2
    Trophy Points:
    135
    #2
    dont use the link anywhere /file.html

    simple

    Regards

    Alex
     
    kmap, Oct 17, 2010 IP
  3. Helado

    Helado Peon

    Messages:
    696
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I was thinking that, so long as Google doesn't find it then that'll be OK. Thanks.
     
    Helado, Oct 17, 2010 IP
  4. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #4
    Life will be easier if you do the exact opposite, and force everything to include the .html instead of what you're trying to do. I don't know where to begin on my list of headaches that I've gotten rid of by not trying to get rid of file extensions. :)
     
    joebert, Oct 20, 2010 IP