Jump to content
MakeWebGames

.htaccess url extension tutorial my version


jcvenom

Recommended Posts

Ok guys have you ever wondered how some sites urls are e.g mydomain.com/home instead of /home.php or html ?

 

Well for people who don't know this they use a haccess or .htaccess now if you want your url to be like for example home instead of home.php then here is my tutorial (can be any file once its in the directory).

 

1.)Ok first look for a file in your main Directory by default the directory is Public_html on Cpanel if files does not exist the create a file called .htaccess

 

2.) Open the htaccess and add this line of code below

 

#---- Made by Jcvenom ----
#---- Establishes a custom 403 error ----
ErrorDocument 403.shtml

#---- Prevents directory from listing in all folders ----
IndexIgnore *


#---- Makes page render(work) without extensions example php or html or asp etc ----

Options +MultiViews


#----End of code do not claim this is yours & do not sell----

 

That should make your Urls work without extension

 

before: mydomain.com/test.php

After: mydomain.com/test

 

Both Urls will still work

 

 

Edited by jcvenom
Link to comment
Share on other sites

This is un-efficient.

By using "Options +MultiViews", you put more strain on your server, by making it "compute" and "find" the file it must serve.

You should be using mod_rewrite for this.

yes you can use mod_rewrite but mod_rewrite may not be activated some hosts and only works on a Apache server

Link to comment
Share on other sites

yes you can use mod_rewrite but mod_rewrite may not be activated some hosts and only works on a Apache server

Then, perhaps you should state that in your "tutorial" (Really, it's just an example). Just for clarity's sake.

Something like... "This is definitely not the most efficient, but if you have no other option, you can do this." should work.

Link to comment
Share on other sites

Then, perhaps you should state that in your "tutorial" (Really, it's just an example). Just for clarity's sake.

Something like... "This is definitely not the most efficient, but if you have no other option, you can do this." should work.

this is a simple way of doing it but there is a advanced way where it automatically hides the extension but this is just a simple way

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...