htaccess mod rewrite help

Discussion in 'Apache' started by jWebXpress, Aug 4, 2007.

  1. #1
    jWebXpress, Aug 4, 2007 IP
  2. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #2
    How do you want the URLs!!
     
    Nintendo, Aug 4, 2007 IP
  3. krt

    krt Well-Known Member

    Messages:
    829
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    120
    #3
    This should get you started, though as Nintendo said, it would help if you told us how you wanted the URLs to look like.
    Option +FollowSymLinks
    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteBase /forum/
    RewriteRule ^detail/(.+)/? detail.php?page=$1 [L]
    RewriteRule ^page/(.+)/? index.php?page=$1 [L]
    </IfModule>
    
    Code (markup):
     
    krt, Aug 4, 2007 IP
  4. jWebXpress

    jWebXpress Well-Known Member

    Messages:
    646
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    140
    #4
    I received this error when I appliead this to the .htaccess:

    Internal Server Error
    The server encountered an internal error or misconfiguration and was unable to complete your request.

    Please contact the server administrator, and inform them of the time the error occurred, and anything you might have done that may have caused the error.

    More information about this error may be available in the server error log.

    Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.

     
    jWebXpress, Aug 4, 2007 IP
  5. jWebXpress

    jWebXpress Well-Known Member

    Messages:
    646
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    140
    #5
    I would like the index.php to look something like below

    index.php?page=10_15_0_0

    to

    index.php?category_name.html

    Here's a snipet I use to pull in the cat name for the meta title:
    <?php echo getCategoryName($url['category_id']); ?>

    Would this work in .htaccess?

    I want a similar outcome for details.php
     
    jWebXpress, Aug 4, 2007 IP
  6. krt

    krt Well-Known Member

    Messages:
    829
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    120
    #6
    Sorry, I wrote "Option" instead of "Options"
    Options +FollowSymLinks
    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteBase /forum/
    RewriteRule ^detail/(.+)/? detail.php?page=$1 [L]
    RewriteRule ^page/(.+)/? index.php?page=$1 [L]
    </IfModule>
    Code (markup):
    If you want to do it by category name:
    Options +FollowSymLinks
    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteBase /forum/
    RewriteRule ^detail/(.+)\.html detail.php?category=$1 [L]
    RewriteRule ^page/(.+)\.html index.php?category=$1 [L]
    </IfModule>
    Code (markup):
    And then search by name using $_GET['category'] in the PHP script or however your app accesses GET vars.
     
    krt, Aug 7, 2007 IP
  7. jWebXpress

    jWebXpress Well-Known Member

    Messages:
    646
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    140
    #7
    Thanks, i'll check it out and report back.
     
    jWebXpress, Aug 7, 2007 IP
  8. jWebXpress

    jWebXpress Well-Known Member

    Messages:
    646
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    140
    #8
    All that happened is that is added this [dbid=b00f1f7d75ebdd28e2eba5e6d1b51b9c] to all links and I think even dropped my PR :(

     
    jWebXpress, Aug 8, 2007 IP
  9. krt

    krt Well-Known Member

    Messages:
    829
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    120
    #9
    dbid=b00f1f7d75ebdd28e2eba5e6d1b51b9c ?

    Is that an obscurely named session ID?

    BTW, if it is a session ID, using mod_rewrite or not would not affect whether it appears in most cases.

    I use this to disable it in .htaccess (requires PHP running as Apache module):
    php_value session.use_cookies 1
    php_value session.use_only_cookies 1
    php_value session.use_trans_sid 0
    Code (markup):
     
    krt, Aug 12, 2007 IP