can i use htaccess php class/functions instead of .htaccess file

Discussion in 'PHP' started by free-designer, Apr 22, 2010.

  1. #1
    hello guys again,
    so im here to ask about something which is really important to me.

    so there is file call ".htaccess" which's do the mod rewrite rules for us

    is there any chance of useing a php class or functions to do the same job as the .htaccess do

    i mean for examble wordpress do have modrewrite rules but they are not useing any of .htaccess file

    but they do have a class, i guess

    so my questions is if this is possible how can i do it.

    thanks :)
     
    free-designer, Apr 22, 2010 IP
  2. sarahk

    sarahk iTamer Staff

    Messages:
    28,901
    Likes Received:
    4,555
    Best Answers:
    123
    Trophy Points:
    665
    #2
    One of my very first sites was using a concept like that, and as you point out WordPress do it too. cakePHP sites use a file called /config/route.php to manage the requests but the guts of the redirect is elsewhere in the code.

    The key thing is that you need your .htaccess to send everything to index.php - without that you're lost.

    Once index.php is run you can identify the $_SERVER parameters which tell you the path requested and any variables - from there you can peel off to the appropriate functions/templates.

    I would warn you against trying to be too clever with it though as your site may become hard to maintain if you have different "types" of content such as a blog, directory and forum. .htaccess can be a lot clearer.
     
    sarahk, Apr 22, 2010 IP