SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Evangelist Redd's Avatar
    Join Date
    Jan 2003
    Posts
    422
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    failed attempt at mod_rewrite, need help

    I've been trying to use mod_rewrite to make my site url friendly.

    I currently have domain.com/file.php?id=12 and I want it to be /file/12/ or something to that effect.

    I've tried
    Code:
    RewriteEngine on 
    RewriteRule ^file/([0-9]+)/?$ /file.php?id=$1 [L]
    But it didn't work. I also added Options +FollowSymlinks but it still didn't do anything.

    Mod_rewrite is installed and is working for other parts of my site (that the htaccess was pre-written) I don't receive any errors, I just don't get the effect.

    Can anyone suggest something else to try?

  2. #2
    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)
    Hi,

    the rules seem fine to me .

    The fact that you didn't have a 40x means that mod_rewrite is doing its job, or at least it seems so.
    Do you have Firebird installed ?
    Using LiveHttpHeaders you could see if for a request as
    example.com/file/12/ you have a 200 status code.

    If you have your website live you can put a link here, or by PrivateMessage to me, and I'll do some tests for you.


    Andrea

    p.s.
    Test 1:
    Before RewriteEngine On add this line:
    foo_directive
    you should see a 500 error then

    Test 2:
    example.com/file.php?id=12 does it work ?

    Test 3:
    example.com/file/12 does it work ?
    No trailing slash.
    Mr Andrea
    Former Hosting Team Advisor
    Former Advisor of '03

  3. #3
    SitePoint Evangelist Redd's Avatar
    Join Date
    Jan 2003
    Posts
    422
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks for the reply! Nothing worked, though.

    I added foo_directive and did get a 500 error. I also received a 500 error when trying the tests you mentioned.

    I have firefox and installed LiveHttpHeaders but those urls give me a 404 anyway, I can only access it via the long url.

    I'm very confused about mod_rewrite. I have a mod_rewrite hack for phpbb that is working for me, as well as the amazon mod_rewrite. Both of those involved hacking the files along with the addition of the htaccess file. However, I see all of these references to just needing the correct htaccess file to make it work. I'm very confused.

  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)
    a)
    Test 1.
    It's fine you have a 500, it means .htaccess was read

    b)
    > I also received a 500 error when trying the tests you mentioned.
    Do you mean this ?
    > example.com/file/12
    Can you post the content of the error_log for that ?

    c)
    You said you have other mod_rewrite rules, can you post the whole content of your .htaccess here ?
    (or PM to me if you have informations you are going to hide)

    d)
    Try this variant:
    RewriteEngine on
    RewriteBase /
    RewriteRule ^file/([0-9]+)/?$ /file.php?id=$1 [L]


    e)
    Also try this variant:
    RewriteEngine on
    RewriteRule ^file/([0-9]+)/?$ file.php?id=$1 [L]

    z)
    The .htaccess is located in your document root, right ?




    Mr Andrea
    Former Hosting Team Advisor
    Former Advisor of '03

  5. #5
    SitePoint Evangelist Redd's Avatar
    Join Date
    Jan 2003
    Posts
    422
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Jackpot!!! Thank you, it's working now. I still have to tweak the links in the files, but the hard part is over.

    Thanks!!


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
  •