0%

Hey! Do you have any query related to front end?

Sign in Sign up

Removing file extensionBack

    • 1
    • 0
    • 40
    • facebook icon
    • twitter icon
    • google plus

Cons of having file extension.

  • URL looks ugly, Such as: http://yourdomain.com/about.html, http://yourdomain.com/services.html etc.
  • Hard to remember.
  • Other person will come to know about technology in which file has been made.

Pros of hiding file extension.

  • Looks clean, Such as: http://yourdomain.com/about or http://yourdomain.com/about/ etc.
  • Easy to remember.
  • Other person will not be able to know about technology in which file has been made.
  • And the best benefit is this, we can change the technology without any SEO effect.

Proceeding to this you must have ".htaccess" file on server. This is the file which does not have any name, it has only extension, i.e. ".htaccess"

If you don't find this file, then create a file in any text editor and save it as ".htaccess", without any name and upload to server. So you will have an .htaccess file to proceed with.

Remove .php Extension from URL

Add these lines to .htaccess file to hide .php

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^([^/]+)/$ $1.php 

Remove .html Extension from URL

Add these lines to .htaccess file to hide .php

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

Add a trailing slash at the end of url

trailing slash is adding extra slash (/) at the end of url, such as http://yourdomain.com/about/ etc. Otherwise page will give 404 error.

Add these lines to .htaccess file to add trailing slash.

# Trailing slash at the end of url
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]

How to comment:

  • Create an account in discuss by clicking on login next to arrow.
  • Create password for discuss and varify your email id, through your mail.
  • Refresh page and comment.

You might also like

  • Force other page to scroll

    Scroll other page at specific location, when related link has been clicked in current page.

    • 265
    • 5
    • 265
    • facebook icon
    • twitter icon
    • google plus
  • Bubbler popup

    This bubbler effect is created by CSS3 transform

    • 283
    • 11
    • 283
    • facebook icon
    • twitter icon
    • google plus
  • Real time content edit

    Edit content at client side.

    • 172
    • 1
    • 172
    • facebook icon
    • twitter icon
    • google plus

Latest quries posted

gopa kumarabout 3 years ago

amit singhabout 3 years ago

rahmat aliabout 3 years ago

mandavi tiwariabout 3 years ago

rahul sharmaabout 3 years ago

Ask question
Latest video
Learn Angular
Profile pic
Guest Back
Username
Password