How to hide extension of html and php file.?

52
584

welcome back to shortlearner.com , In this tutorial  we will see how to hide extension of files using .htaccess
before start learning first of all we should  know about .htaccess file
what is .htaccess

hide extension of url using htaccess
in a simple words we can say that the .htaccess is a configuration file for use on web servers running the
Apache Web Server software. When a .htaccess file is placed in a directory
which is in turn ‘loaded via the Apache Web Server’,
then the .htaccess file is detected and executed by the Apache Web Server software.

Also Read :
PHP Login Script With Remember me.
Change password using javascript, php and mysqli.
Password and Confirm Password Validation Using JavaScript
Check Email is Already Registered in Database using Ajax and JavaScript.
How to hide extension of html and php file.?

Benefits of using .htaccess

  • Redirect the user to different page
  • Password protect a specific directory
  • Block users by IP
  • Preventing hot linking of your images
  • Rewrite URIs
  • Specify your own Error Documents

In this tutorial we make 3 php pages and hide there extensions using .htaccess file.
index.php

<!DOCTYPE HTML>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title>Remove .php extension with .htaccess by http://mainvps.shortlearner.com/</title>
         
        
        
    </head>
<body>
 
<center>

<div id="menu">
<ul>
	<li><a href="index">home</a></li>
    <li><a href="login">login</a></li>
    <li><a href="signup">signup</a></li>
  
</ul>
</div>

<div id="body">

<h1>This is index.php page | see the url in addressbar</h1> <br />


</div>
</center>
 
</body>
</html>

Signup.php

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title>Remove .php extension with .htaccess by http://mainvps.shortlearner.com/</title>
         

        
    </head>
<body>
 
<center>

<div id="menu">
<ul>
	<li><a href="index">home</a></li>
    <li><a href="login">login</a></li>
    <li><a href="signup">signup</a></li>
   
</ul>
</div>

<div id="body">

<h1>This is signup.php page | see the url in addressbar</h1>

</div>
</center>
</body>
</html>

Login.php

<!DOCTYPE HTML>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title>Remove .php extension with .htaccess by http://mainvps.shortlearner.com/</title>
         
        <link rel="stylesheet" href="style.css" type="text/css" />
        
    </head>
<body>
 
<center>

<div id="menu">
<ul>
	<li><a href="index">home</a></li>
    <li><a href="login">login</a></li>
    <li><a href="signup">signup</a></li>
   
</ul>
</div>

<div id="body">

<h1>This is login.php page | see the url in addressbar</h1><br />



</div>
</center>
</body>
</html>

Save below code with .htaccess

<IfModule mod_rewrite.c>
RewriteEngine on

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


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


</IfModule>

 

52 COMMENTS

  1. When I read an article on this topic, casino online the first thought was profound and difficult, and I wondered if others could understand.. My site has a discussion board for articles and photos similar to this topic. Could you please visit me when you have time to discuss this topic?

  2. Looking at this article, I miss the time when I didn’t wear a mask. baccaratcommunity Hopefully this corona will end soon. My blog is a blog that mainly posts pictures of daily life before Corona and landscapes at that time. If you want to remember that time again, please visit us.

  3. [url=https://over-the-counter-drug.com/#]over the counter allergy medicine[/url] eczema treatment over the counter

  4. [url=https://over-the-counter-drug.com/#]eczema treatment over the counter[/url] best over the counter skin tag removal

  5. [url=https://over-the-counter-drug.com/#]over the counter essentials united healthcare[/url] pink eye over the counter medicine

  6. [url=https://over-the-counter-drug.com/#]over the counter inhaler[/url] instant female arousal pills over the counter

  7. First of all, thank you for your post. casinocommunity Your posts are neatly organized with the information I want, so there are plenty of resources to reference. I bookmark this site and will find your posts frequently in the future. Thanks again ^^

  8. Everything information about medication. Read here.
    [url=https://stromectolst.com/#]ivermectin drug[/url]
    What side effects can this medication cause? Cautions.

  9. Top 100 Searched Drugs. Read here.
    [url=https://stromectolst.com/#]stromectol online pharmacy[/url]
    Cautions. Generic Name.

  10. Get here. Generic Name.
    [url=https://stromectolst.com/#]ivermectin 9 mg[/url]
    Commonly Used Drugs Charts. Best and news about drug.

  11. Everything about medicine. Everything about medicine.
    [url=https://stromectolst.com/#]stromectol nz[/url]
    Everything about medicine. Some are medicines that help people when doctors prescribe.

  12. Learn about the side effects, dosages, and interactions. Read information now.
    [url=https://stromectolst.com/#]stromectol covid 19[/url]
    All trends of medicament. Best and news about drug.

  13. Read here. Comprehensive side effect and adverse reaction information.
    [url=https://stromectolst.com/#]stromectol usa[/url]
    Actual trends of drug. Some trends of drugs.

  14. Comprehensive side effect and adverse reaction information. Comprehensive side effect and adverse reaction information.
    [url=https://stromectolst.com/#]stromectol without prescription[/url]
    Get information now. Everything about medicine.

  15. Comprehensive side effect and adverse reaction information. Get warning information here.
    [url=https://stromectolst.com/#]stromectol online canada[/url]
    Everything information about medication. Top 100 Searched Drugs.

  16. Everything information about medication. Comprehensive side effect and adverse reaction information.
    [url=https://stromectolst.com/#]stromectol price[/url]
    Drug information. Everything information about medication.

  17. Top 100 Searched Drugs. Prescription Drug Information, Interactions & Side. https://avodart.science/# where to get avodart without dr prescription
    Learn about the side effects, dosages, and interactions. drug information and news for professionals and consumers.

  18. Drug information. What side effects can this medication cause?
    [url=https://levaquin.science/#]buy levaquin prices[/url]
    Read now. Actual trends of drug.

  19. Everything what you want to know about pills. Commonly Used Drugs Charts.
    [url=https://mobic.store/#]can i buy mobic pill[/url]
    Top 100 Searched Drugs. drug information and news for professionals and consumers.

LEAVE A REPLY

Please enter your comment!
Please enter your name here