Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Page 1 of 2 12 LastLast
Results 1 to 10 of 12
  1. #1
    Join Date
    Jul 2007
    Location
    Swindon
    Posts
    990
    Tokens
    125

    Default [Tut] Mod-Rewrite (.htaccess)

    Think your links look ugly eg.
    www.yoursite.com/index.php?page=test&skin=blue&language=eng&time=uk

    Well .htaccess has made it alot easier for you to change this to something like;
    www.yoursite.com/test/blue/eng/uk/

    What is .htaccess?
    .htaccess (hypertext access) is the default name of Apache's directory-level configuration file. It provides the ability to customize configuration for requests to the particular directory.
    .htaccess files are commonly used for:
    • Authorization, authentication: .htaccess files are often used to specify the security restrictions for the particular directory, hence the filename "access". The .htaccess file is often accompanied by an .htpasswd file which stores valid usernames and their passwords.
    • Customized error responses: Changing the page that is shown when a server-side error occurs, for example HTTP 404 Not Found.
    • Rewriting URLs: Various server-side PHP scripts use .htaccess to rewrite "ugly" URLs to shorter and prettier ones.
    Taken from; http://en.wikipedia.org/wiki/Htaccess

    Here's how you can do it.
    So first of all we turn on and make sure all the links follow.
    Code:
    Options +FollowSymLinks
    RewriteEngine On
    Now this is where it gets hard, lets just test with one,
    Code:
    RewriteRule ^([A-Za-z0-9-]+)/$ index.php?page=$1 [L]
    this will change yoursite.com/index.php?page=test to yoursite.com/test/ (remember the last / ).

    Now we will do the rest,

    RewriteRule
    Code:
    ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/$ index.php?page=$1&skin=$2&language=$3&time=$4 [L]
    You will need to save that in the appropriate directory.

    Code breakdown,
    Code:
    ([A-Za-z0-9-]+)
    This allows it to either be UPPERCASE lowercase or BoTh or numbers (0-9)
    you can allow it just for numbers,
    Code:
    ([0-9]+)
    Code:
    page=$1
    the $1 means that its the first in the url, like yoursite.com/first/second/third i think thats all enjoy.

    OR you could use RichardKnox method which is also very good and easier to use thanks ,

    You overcomplicated it.

    http://www.yoursite.com/index.php?pa...ge=eng&time=uk

    to

    www.yoursite.com/test/blue/eng/uk/

    doesn't require as much as you;ve put. Try

    Code:
    RewriteEngine On

    RewriteRule (.*)/(.*)/(.*)/(.*)/ index.php?page=$1&skin=$2&language=$3&time=$4

    UPDATE:
    Iv had a few PMs asking me how to access .htaccess so heres how:
    Log into Cpanel and click on "File Manager". You should then get a pop-up asking which directory to open, if you look a bit further down on the pop-up you should see two Check boxs. Check "Show Hidden Files" and click "Go".
    Now go to www if your not allredy in there, and you should see .htaccess
    [ Credit to .:Jack120:. ]

    Edited By Sunny. (Forum Moderator): Updated as requested.
    Last edited by Sunny.; 07-10-2007 at 03:55 PM.

  2. #2
    Join Date
    Jul 2007
    Location
    Scotland
    Posts
    529
    Tokens
    0

    Default

    You overcomplicated it.

    http://www.yoursite.com/index.php?pa...ge=eng&time=uk

    to

    www.yoursite.com/test/blue/eng/uk/

    doesn't require as much as you;ve put. Try

    Code:
    RewriteEngine On
    
    RewriteRule (.*)/(.*)/(.*)/(.*)/ index.php?page=$1&skin=$2&language=$3&time=$4
    But, well done.

  3. #3
    Join Date
    Jul 2007
    Location
    Swindon
    Posts
    990
    Tokens
    125

    Default

    Quote Originally Posted by RichardKnox View Post
    You overcomplicated it.

    http://www.yoursite.com/index.php?pa...ge=eng&time=uk

    to

    www.yoursite.com/test/blue/eng/uk/

    doesn't require as much as you;ve put. Try

    Code:
    RewriteEngine On
    
    RewriteRule (.*)/(.*)/(.*)/(.*)/ index.php?page=$1&skin=$2&language=$3&time=$4
    But, well done.
    Oh sorry, i've never came across that way as i've always used the way i posted, but if it works then yeh use it Thank you richard.

  4. #4
    Join Date
    Jul 2007
    Location
    Scotland
    Posts
    529
    Tokens
    0

    Default

    Well (.*) is a wildcard. Meaning (.*) can be substitued for any value, in the case of $1 "test".

  5. #5
    Join Date
    Jul 2007
    Location
    Swindon
    Posts
    990
    Tokens
    125

    Default

    so it allows anything wouldnt that be a bit unsafe specially using mysql or.. so you could use a mysql attack like that where as if you only allow certain characters?

  6. #6
    Join Date
    Jul 2007
    Location
    Scotland
    Posts
    529
    Tokens
    0

    Default

    Well no, not really. Cause if your using it, you should be cleaning your GET url's anyway.

  7. #7
    Join Date
    Jul 2007
    Location
    Swindon
    Posts
    990
    Tokens
    125

    Default

    true true. Thanks.

  8. #8
    Join Date
    May 2006
    Location
    Hull
    Posts
    7,701
    Tokens
    2,430
    Habbo
    Moh

    Latest Awards:

    Default

    what if I wanted to change:
    /pages/PAGEGROUP/PAGENAME
    to:
    /PAGENAME

    Do I have to add them all manualy? The groups that is

  9. #9
    Join Date
    Jul 2007
    Location
    Swindon
    Posts
    990
    Tokens
    125

    Default

    could you explain im a little confused, what is the url so far?

  10. #10
    Join Date
    Jul 2007
    Location
    Scotland
    Posts
    529
    Tokens
    0

    Default

    No, you use (.*)

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •