SitePoint Sponsor

User Tag List

Results 1 to 12 of 12
  1. #1
    SitePoint Wizard co.ador's Avatar
    Join Date
    Apr 2009
    Posts
    1,054
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    What would be the best way to organize a url structure in your website?

    I would like to know what would be the steps to take and go ahead and organize your code as well?

    All in a way for production server and good for the SEO?

  2. #2
    SitePoint Wizard rguy84's Avatar
    Join Date
    Sep 2005
    Location
    Durham, NC
    Posts
    1,659
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    can you clarify? Are you talking about file structure, which your title alludes to. Or do you mean the code in the files?
    Ryan B | My Blog | Twitter

  3. #3
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,684
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    If you're wanting to change access to
    domain.com/page.php?user=myname&page=5
    into
    domain.com/page/myname/5

    Then you will require mod_rewrite techniques.

    These techniques are not setup with PHP code, but are instead done via your server setup.
    The most you will need to do in your PHP code is to update the web page links.

    The Apache Configuration forum is the best place to get advice about this.

    They even have a sticky thread called mod_rewrite Resources and articles such as Learn Apache mod_rewrite: 13 Real-world Examples
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  4. #4
    SitePoint Zealot
    Join Date
    Jul 2007
    Location
    Macomb, MI USA
    Posts
    138
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    inClick Ad Server - Start Your Own Performance Based Ad Network
    Key Features | Download inClick Now | Free Ad Server Hosting Offer

  5. #5
    SitePoint Wizard co.ador's Avatar
    Join Date
    Apr 2009
    Posts
    1,054
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    @rguy84 I mean both, The code in the file is what I am missing after @pmw57 and @inclick explanation on friendly urls and update the web page links as well....

    I will those techniques the mod_rewrite technique and give it a try.

    thank you very much.

  6. #6
    SitePoint Zealot
    Join Date
    Jul 2007
    Location
    Macomb, MI USA
    Posts
    138
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is the .htaccess code I used for PatchSales:

    RewriteEngine On
    RewriteRule ^category/([^/]*)/([^/]*)/([^/]*)\.html$ /index.php?pageid=itemview&category=$1&page=$2&pagetitle=$3 [L]
    RewriteRule ^patch/([^/]*)/([^/]*)\.html$ /index.php?pageid=itemviewdetail&detail=$1&pagetitle=$2 [L]
    inClick Ad Server - Start Your Own Performance Based Ad Network
    Key Features | Download inClick Now | Free Ad Server Hosting Offer

  7. #7
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,684
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by inclick View Post
    This is the .htaccess code I used for PatchSales:

    RewriteEngine On
    RewriteRule ^category/([^/]*)/([^/]*)/([^/]*)\.html$ /index.php?pageid=itemview&category=$1&page=$2&pagetitle=$3 [L]
    RewriteRule ^patch/([^/]*)/([^/]*)\.html$ /index.php?pageid=itemviewdetail&detail=$1&pagetitle=$2 [L]
    Thank you inclick, but I feel that this belongs much more appropriately in the Apache Configuration forum.

    People can also find there the article called Learn Apache mod_rewrite: 13 Real-world Examples from which they can match them up to their own requirements.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  8. #8
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,139
    Mentioned
    16 Post(s)
    Tagged
    3 Thread(s)
    You can also opt to make your life easy and decode the URL within the application. That is the path I always choose besides rewriting everything to the application entry point. That way if certain routes require special treatment your not left to hack the .htaccess file.

  9. #9
    SitePoint Wizard co.ador's Avatar
    Join Date
    Apr 2009
    Posts
    1,054
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    @Odzz

    Do you have any reference that shows how to re-write the url within the application?


    I was in the mod_rewrite sitepoint tutorial and didn find the second line below

    #LoadModule rewrite_module modules/mod_rewrite.so
    #AddModule mod_rewrite.c

    in the httpd.conf file.

    what could be done in that place?

  10. #10
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,684
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by co.ador View Post
    I was in the mod_rewrite sitepoint tutorial and didn find the second line below

    #LoadModule rewrite_module modules/mod_rewrite.so
    #AddModule mod_rewrite.c

    in the httpd.conf file.

    what could be done in that place?
    You will obtain better answers to this by asking this in the Apache Configuration forum.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  11. #11
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,139
    Mentioned
    16 Post(s)
    Tagged
    3 Thread(s)
    With path info supported the simplest solution is to explode everything following the entry script by /.

    PHP Code:
    $arrRequestArgs = isset($_SERVER['PATH_INFO'])?explode('/',trim($_SERVER['PATH_INFO'],'/')):array();
    echo 
    '<pre>',print_r($arrRequestArgs),'</pre>'
    So this url: index.php/Product/My-Products-Name/

    Would decode to: [0=>Product,1=>My-Products-Name]

  12. #12
    SitePoint Wizard co.ador's Avatar
    Join Date
    Apr 2009
    Posts
    1,054
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you guys.


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
  •