SitePoint Sponsor

User Tag List

Results 1 to 11 of 11

Thread: Mod Rewrite?

  1. #1
    SitePoint Wizard dragonfly_7456's Avatar
    Join Date
    Dec 2002
    Location
    Moscow, USSR
    Posts
    1,092
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Mod Rewrite?

    I'm linking to all my pages within my site using index.php?page=whatever

    Well, how would I link from the index.php page to say a page in a subdirectory, say for example "articles"?

    So, in other words, how do I link to /articles/articlename.php using index.php?page= ?

    Should I use mode rewrite or what?
    Content Writing Service - Get custom SEO articles for 10$

  2. #2
    SitePoint Evangelist
    Join Date
    Oct 2001
    Posts
    439
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    something like this:

    ReWriteEngine On
    RewriteRule ^articles/([^/]+)/?$ index.php?page=$1 [L]

    I have done something similar and it works ok....although there are much more experienced mod_rewriters around here that will provide better help

  3. #3
    SitePoint Wizard dragonfly_7456's Avatar
    Join Date
    Dec 2002
    Location
    Moscow, USSR
    Posts
    1,092
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah, I'm waiting for Pippo to show up... Wonder where he is
    Content Writing Service - Get custom SEO articles for 10$

  4. #4
    FreeBSD The Power to Serve silver trophy pippo's Avatar
    Join Date
    Jul 2001
    Location
    Italy
    Posts
    4,514
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    >> Wonder where he is
    I've always been here,
    but I didn't answer because I liked mvd's answer...;-)


    :-) Andrea
    Mr Andrea
    Former Hosting Team Advisor
    Former Advisor of '03

  5. #5
    SitePoint Wizard dragonfly_7456's Avatar
    Join Date
    Dec 2002
    Location
    Moscow, USSR
    Posts
    1,092
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Alright. So, using his way, I should right a rule for EVERY sub folder that I might want to redirect to?
    Content Writing Service - Get custom SEO articles for 10$

  6. #6
    SitePoint Wizard dragonfly_7456's Avatar
    Join Date
    Dec 2002
    Location
    Moscow, USSR
    Posts
    1,092
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    And, what would the link then look like? index.php?page=articles/bla.php

    ???
    Content Writing Service - Get custom SEO articles for 10$

  7. #7
    FreeBSD The Power to Serve silver trophy pippo's Avatar
    Join Date
    Jul 2001
    Location
    Italy
    Posts
    4,514
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dragon,
    the belowe rule posted in an .htaccess located on the document root

    RewriteRule ^articles/([^/]+)/?$ index.php?page=$1 [L]

    means that every request as
    /articles/something_without_a_slash
    will be redirected internally to
    /index.php?page=something_without_a_slash

    Could you please post some examples of URIs ?

    Please post the request and where you want to redirect it,
    so I might be able to write some rules matching your needs.


    Thanks,
    :-) Andrea
    Mr Andrea
    Former Hosting Team Advisor
    Former Advisor of '03

  8. #8
    Non-Member Icheb's Avatar
    Join Date
    Mar 2003
    Location
    Germany
    Posts
    1,474
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is it true that Mod Rewrite only works with servers where PHP is installed as a module? If so, why is that?

  9. #9
    FreeBSD The Power to Serve silver trophy pippo's Avatar
    Join Date
    Jul 2001
    Location
    Italy
    Posts
    4,514
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Icheb
    Is it true that Mod Rewrite only works with servers where PHP is installed as a module? If so, why is that?
    I can't answer for direct experience but I never heard that it won't work.
    The main problem is that most PHP gurus will tell you that running php as cgi is a bad choice (don't ask me why...).


    :-) Andrea
    Mr Andrea
    Former Hosting Team Advisor
    Former Advisor of '03

  10. #10
    SitePoint Wizard samsm's Avatar
    Join Date
    Nov 2001
    Location
    Atlanta, GA, USA
    Posts
    5,011
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The word on the street is that PHP is faster as a module.

    I recently acquired a book "Writting Apache Modules with Perl and C" ($5 at MicroCenter!) that explains a weakness of CGI:

    CGI is not the highest performance environment. The Achilles' heel of a CGI script is that every time a web server needs it, the server must set up the CGI environment, read the script into memory, and launch the script.
    ...
    as load increases, the process creation bottleneck eventually turns formally snappy scripts into molasses.
    That seems like a likely reason a server module without the cgi overhead would be a better choice.
    Using your unpaid time to add free content to SitePoint Pty Ltd's portfolio?

  11. #11
    gingham dress, army boots... silver trophy redux's Avatar
    Join Date
    Apr 2002
    Location
    Salford / Manchester / UK
    Posts
    4,838
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Icheb
    Is it true that Mod Rewrite only works with servers where PHP is installed as a module? If so, why is that?
    nope, i've had it running without PHP many times before (using cgi, hooked-in tomcat, etc)
    re·dux (adj.): brought back; returned. used postpositively
    [latin : re-, re- + dux, leader; see duke.]
    WaSP Accessibility Task Force Member
    splintered.co.uk | photographia.co.uk | redux.deviantart.com


Bookmarks

Posting Permissions

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