Forums

  • # April 21, 2012 at 8:53 pm

    Hello!

    I am attempting to hide the .html file extension in the url – and redirect when manually typed in. I am using the .htaccess to accomplish this, however I am not seeing any results. Any help is much appreciated. Thank You.

    The code:

    <br />
    <br />
    RewriteCond %{REQUEST_FILENAME} !-d<br />
    RewriteCond %{REQUEST_FILENAME}.html -f<br />
    RewriteRule ^(.*)$ $1.html<br />
    <br />
    
    # April 22, 2012 at 2:20 pm

    Did you set the base and turn the engine on before hand?

    RewriteBase /

    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}.html -f
    RewriteRule ^(.*)$ $1.html
    # April 25, 2012 at 10:47 pm

    @NSR

    Here is an answer from stackoverflow.com:

    RewriteEngine On
    RewriteBase /
    RewriteCond %{SCRIPT_FILENAME} !-f
    RewriteCond %{SCRIPT_FILENAME} !-d
    RewriteRule ^(.*)$ $1.html [NC,L]

    If the person tried adding a .html extension to the URL, wouldn’t it automatically be removed with the code above?

    # August 27, 2012 at 9:05 pm

    @NSR
    Would you name the file name.htaccess in order for the file to work?

    # August 27, 2012 at 9:56 pm

    @NSR, this is a little off subject but i was wondering what would you be using this for? The reason i am asking because i have seem methodology before but im only a college student and havent really seen any implementation for this. So basically, what real world scenario are you trying to achieve by removing the extension?

    Good luck with finding the answer btw.

    # August 28, 2012 at 12:25 am

    Well the code that Chris wrote in the PHP snippets works just fine, but you have to link to /about rather than /about.html or something

    # September 15, 2012 at 12:42 pm

    i want to hide url in subdirectory
    http://www.123musiq.biz/folder/page.html
    to
    http://www.123musiq.biz/folder/page

    .htaccess tag added in subdirectory but it doesn’t work.
    the tag is
    RewriteCond %{REQUEST_FILENAME} !-dRewriteCond %{REQUEST_FILENAME}.html -fRewriteRule ^(.*)$ $1.html
    what can ido? what is the code for hide url extension in subdirectory file?

    # September 27, 2012 at 3:56 am

    Hello all user i want hide page how can i do? this my url **http://khmerera.com/detail.php?ads=$id** but now i want hide detail.php how can i do it i want have like this **http://khmerera.com/?ads=$id **please help me Thz!

    # November 4, 2012 at 11:54 am

    Basically it makes them look “pretty”.

    # February 4, 2013 at 8:05 pm

    @Rugg:
    Hi Rugg, I follow your code below

    RewriteCond %{THE_REQUEST} /(.+/)?index(.html)?(?.*)? [NC]
    RewriteRule ^(.+/)?index(.html)?$ /%1 [R=301,L]

    RewriteCond %{ENV:REDIRECT_STATUS} ^$
    RewriteRule ^(.+).html$ /$1 [R=301,L]

    RewriteCond %{SCRIPT_FILENAME}.html -f
    RewriteRule [^/]$ %{REQUEST_URI}.html [QSA,L]

    and it works fine.
    However, because I use 2 files for contact page which is contact.html and contact.php
    When I type /contact the html page cannot load.

    Do you know why does it happen and how to fix it?
    Thanks a lot.

    # May 20, 2013 at 6:21 am

    **I there I Am new with httacces **

    Extension .html but i can hide using this rule .. help

    # August 9, 2013 at 10:28 pm

    Hi All,

    I can’t get this to work at all :-/

    The pages load fine, I get no errors, but the .html extensions are still visible in the browser, any ideas?

    Code:

    <IfModule mod_rewrite.c>
    Options +FollowSymLinks
    RewriteBase /
    RewriteEngine on
    RewriteCond %{REQUEST_fileNAME} !-d
    RewriteCond %{REQUEST_fileNAME} !-f
    RewriteRule ^(([^/]+/)*[^./]+)$ /$1.html [L]
    </IfModule>

Viewing 12 posts - 1 through 12 (of 12 total)

You must be logged in to reply to this topic.

icon-anchoricon-closeicon-emailicon-linkicon-logo-staricon-menuicon-nav-guideicon-searchicon-staricon-tag