Hide extension in .htaccess

后端 未结 4 507
刺人心
刺人心 2021-01-15 03:50

Hi All i have a problem that my file have .html extention but i want that when the file open in brownser the extention had hidden.e.g file.html to file. Advance thanks

相关标签:
4条回答
  • 2021-01-15 04:29

    Your link must be like this

    <a href="example">Example</a>
     Instead of
    <a href="example.php">Example</a>
    

    Then add this to your .htaccess file

     RewriteCond ^example example.php [L]
    
    0 讨论(0)
  • 2021-01-15 04:33

    In your .htaccess file use this:

    RewriteEngine on  
    RewriteCond %{REQUEST_FILENAME} !-d  
    RewriteCond %{REQUEST_FILENAME}\.html -f  
    RewriteRule ^(.*)$ $1.html
    

    Now you can use lins like http://www.mysite.com/contact rather than http://www.mysite.com/contact.html.

    Hope this helps!

    0 讨论(0)
  • 2021-01-15 04:41
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^/]+)/$ $1.php
    RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
    RewriteRule (.*)$ /$1/ [R=301,L]
    

    Example yoursite.com/wallpaper.html to yoursite.com/wallpaper/

    0 讨论(0)
  • 2021-01-15 04:44

    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}.html -f
    RewriteRule ^(.*)$ $1.html

    this one is ok for single extensions in one website. I am using multiple extensions in same website for example index.html and contact.php.

    How can i use this code ?

    0 讨论(0)
提交回复
热议问题