How to Make Site url friendly

Discussion in 'Computer Programming, Emulation, and Game Modding' started by 3XPOS3D, Dec 13, 2015.

  1. 3XPOS3D
    OP

    3XPOS3D Newbie

    Newcomer
    4
    4
    Dec 9, 2015
    notice this for apache based servers.

    1.First we need to create a file called
    .htaccess in root folder.

    2.Let start by enabling mod re-write paste the below code in to the
    .htaccess file.

    Code:
    ## Turn On the Rew-Writing Engine
    RewriteEngine On   
    ok great just an fair warning not every host have this enabled so might not work for some.

    3.Let say your home page is home.php we going to me it /home/ so the domain will look something like
    mysite.com/home/ so let copy the below code to .htaccess

    Code:
    ## Base Dir for home
    RewriteRule ^home/$ home.php
    great this create the rule for the virtual folder know your code should look like below

    Code:
    ## Turn On the Rew-Writing Engine
    RewriteEngine On
    
    ## Base Dir for  home
    RewriteRule ^home/$home.php
    4.Doing great this is the hard part where your calling css & java files or images you will need to do this

    Code:
    imgs/slider/slider.jpg change to  ../img/slider/slider.jpg
    or for css

    Code:
    css/bootstrap.css change to  ../css/bootstrap.css
    5.ok you get the idea how it works so know you can don the second rule for a new page example below.

    Code:
    ## Base Dir for about
    RewriteRule ^about/$ about.php
    
    6.As you can see above code is for about page so you get how this works know i hope this is easy enough to follow & have a nice day :P
     
    Last edited by 3XPOS3D, Dec 13, 2015
  2. Essometer

    Essometer GBAtemp Regular

    Member
    250
    148
    Oct 22, 2010
    Germany
    Enger
    I'm sorry, what?
     
  3. Jack_Sparrow

    Jack_Sparrow Ruthless Pirate

    Banned
    855
    477
    Nov 17, 2015
    United States
    The Black Pearl
    What?
     
  4. Voxel

    Voxel Clumsy Coder

    Member
    GBAtemp Patron
    Voxel is a Patron of GBAtemp and is helping us stay independent!

    Our Patreon
    5,155
    5,793
    Jun 27, 2015
    United Kingdom
    England, UK
    [​IMG]
     
    Jack_Sparrow likes this.
  5. RainCode

    RainCode The Temper that Tampers

    Member
    162
    57
    Sep 29, 2015
    /dev/null
    This is to make site URLs look clean.
    It looks like this makes it so if you were to go to http://example.com/about then it would pick up about.php but won't redirect you to it.

    Note that this code (in the type of format it's using) is for Apache only.
     
    Last edited by RainCode, Dec 13, 2015
    Jack_Sparrow, 3XPOS3D and Voxel like this.
  6. 3XPOS3D
    OP

    3XPOS3D Newbie

    Newcomer
    4
    4
    Dec 9, 2015
    Does what RainCode said sorry if my Tutorial are not the best i don't normally type tutorial up so i will do my best to keep them noob friendly
     
    Voxel likes this.
  7. TotalInsanity4

    TotalInsanity4 GBAtemp Supreme Overlord

    Member
    6,939
    6,925
    Dec 1, 2014
    United States
    Under a rock
    You should have this moved to the tutorials section
     
    Voxel likes this.