mode_rewrite and .htaccess

Discussion in 'PHP' started by c4cyber, Oct 25, 2007.

  1. #1
    Hi !
    i need help related to mod_rewrite by .htaccess

    the scenario is

    dynamic url : localhost/cylinks/cat.php?id=4
    static url : localhost/cylinks/cat/id/4

    .htaccess file is saved in root directory (where index.php & cat.php exists)

    .htaccess contains::

    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /


    # Set the default handler
    DirectoryIndex index.php

    # URL rewrite rules
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    ## Category redirect
    RewriteRule ^cylinks/cat/id/(.*)/$ /cat.php?id=$1 [L]
    </IfModule>


    but i'm getting 404 not found error.
    what's the problem ?
    please help ?
    i'm using apache 1.3.x ..
    is there any way to check if actually mod_rewrite module is working at my host/pc ?
     
    c4cyber, Oct 25, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    
    /cat.php?id=$1 [L]
    
    Code (markup):
    Try removing the forward slash there.

    Or try this:
    
    cylinks/cat.php?id=$1 [L]
    
    Code (markup):
     
    nico_swd, Oct 25, 2007 IP
  3. bradical1379

    bradical1379 Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Your problem is in your absolute path to your cat.php file.

    /cat.php?id=$1 would actually be at localhost/cat.php?id=$1

    Change it to match your path to the file, or, add a virtual host for the directory cylinks, so you can continue to develop on a 1-to-1 basis.
     
    bradical1379, Oct 25, 2007 IP
  4. c4cyber

    c4cyber Well-Known Member

    Messages:
    1,040
    Likes Received:
    27
    Best Answers:
    1
    Trophy Points:
    150
    #4
    Thankyou boys ! it's working now
     
    c4cyber, Oct 26, 2007 IP