How to rewrite ".html/..." to ".html"

Discussion in 'Apache' started by georgi, Nov 15, 2013.

  1. #1
    Hi folks,

    Could someone, please, help me with the following: in my .htaccess I would like to rewrite all URL-s ending on
    ".html/any_characters"
    to
    ".html"

    Your help is greatly appreciated.
     
    georgi, Nov 15, 2013 IP
  2. Nigel Lew

    Nigel Lew Notable Member

    Messages:
    4,642
    Likes Received:
    406
    Best Answers:
    21
    Trophy Points:
    295
    #2
    May need to see a link but try
    RewriteRule ^(.*)\.html(.*)$ $1.html [R=301, L]

    Not entirely sure if that is going to work though.

    hope that helps,
    Nigel
     
    Nigel Lew, Nov 15, 2013 IP
  3. MBDungo

    MBDungo Active Member

    Messages:
    163
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    58
    #3
    Try to use this one:
    RewriteRule ^/?(.+)\.html/(.+)$ /$1.html [L]
    Code (markup):
     
    MBDungo, Nov 15, 2013 IP
  4. georgi

    georgi Active Member

    Messages:
    27
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    86
    #4
    RewriteRule ^(.*)\.html(.*)$ $1.html [R=301, L]
    Code (markup):
    returns "500" Internal Server Error

    RewriteRule ^/?(.+)\.html/(.+)$ /$1.html [L]
    Code (markup):
    no changes
     
    georgi, Nov 16, 2013 IP
  5. MBDungo

    MBDungo Active Member

    Messages:
    163
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    58
    #5
    If you're going to rewrite "/$var.html/$any" into "/$var.html" there maybe a conflict on your .htaccess file.

    Or if you're using such as a free web host try to wait a minute for your web server.
     
    MBDungo, Nov 16, 2013 IP
  6. georgi

    georgi Active Member

    Messages:
    27
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    86
    #6
    I removed all other lines from my .htaccess and still getting "500"
     
    georgi, Nov 16, 2013 IP
  7. MBDungo

    MBDungo Active Member

    Messages:
    163
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    58
    #7
    Make sure there is
    RewriteEngine on
    Code (markup):
    on your htaccess.

    How about the other .htaccess file from different directory.
     
    MBDungo, Nov 16, 2013 IP
  8. georgi

    georgi Active Member

    Messages:
    27
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    86
    #8
    no others
     
    georgi, Nov 17, 2013 IP