Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    Regular Coder
    Join Date
    Mar 2007
    Location
    Quebec
    Posts
    261
    Thanks
    6
    Thanked 7 Times in 7 Posts

    mod_rewrite woes

    Well, I decided to try playing with Apache's mod_rewrite feature and so far it hasn't been very fun. I haven't been able to get it to work! I edited my .htaccess file, uploaded it to the correct directory (infact I uploaded to all pertaining directories. ex: /projects/rewrite/ -> all folders have a copy placed in it) and yet it still doesn't work. What's worse is I'm only using a basic example! I'm having test.html show test2.html's content but not show test2.html in the address bar.

    .htaccess
    PHP Code:
    <Files 403.shtml>
    order allow,deny
    allow from all
    </Files>

    deny from 210.49.13.
    deny from 211.30.246.

    RewriteEngine on
    RewriteRule 
    ^test.htmltest2.html 
    test.html
    PHP Code:
    <html>
    <
    head><title>Test</title>
    </
    head>
    <
    body>
    test
    </body>
    </
    html
    test2.html
    PHP Code:
    <html>
    <
    head><title>Test2</title>
    </
    head>
    <
    body>
    test2 lalalala
    </body>
    </
    html
    I've checked with my host and mod_rewrite is enabled.
    The scripts reside at www.ridemtl.com/projects/rewrite/test.html | test2.html and also in the root directory.

    Can anyone help?

    P.S: I used this tutorial

  • #2
    Senior Coder shyam's Avatar
    Join Date
    Jul 2005
    Posts
    1,563
    Thanks
    2
    Thanked 163 Times in 160 Posts
    perhaps u should add

    Code:
    RewriteBase /projects/rewrite
    You never have to change anything you got up in the middle of the night to write. -- Saul Bellow

  • Users who have thanked shyam for this post:

    fl00d (11-21-2007)

  • #3
    Regular Coder
    Join Date
    Mar 2007
    Location
    Quebec
    Posts
    261
    Thanks
    6
    Thanked 7 Times in 7 Posts
    thank you very much! that's what it was missing!

  • #4
    Regular Coder
    Join Date
    Mar 2007
    Location
    Quebec
    Posts
    261
    Thanks
    6
    Thanked 7 Times in 7 Posts
    hmph I'm having more problems =/
    Does anything look wrong with this line? I can't seem to get it to work!
    PHP Code:
    RewriteRule ^new/([^0-9]+)/?$ template.php?id=$[L
    I'm trying to get it to work with the page www.ridemtl.com/new/template.php so that
    /new/1/ = /new/template.php?id=1 (currently ID only has 1 value, which is 1)

    Any idea's? I thought I had this down but apparently I don't =/

  • #5
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,642
    Thanks
    2
    Thanked 405 Times in 397 Posts
    Try
    PHP Code:
    RewriteRule ^new/([0-9]+)/?$ /new/template.php?id=$[L
    Last edited by Inigoesdr; 11-27-2007 at 02:46 AM.

  • #6
    Regular Coder
    Join Date
    Mar 2007
    Location
    Quebec
    Posts
    261
    Thanks
    6
    Thanked 7 Times in 7 Posts
    Same problem. Page still isn't found Oh well, I'll give it another go tomorrow. Thanks for the help though.

  • #7
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,642
    Thanks
    2
    Thanked 405 Times in 397 Posts
    Whoops. You'll want to remove that circumflex.

  • #8
    Regular Coder
    Join Date
    Mar 2007
    Location
    Quebec
    Posts
    261
    Thanks
    6
    Thanked 7 Times in 7 Posts
    OK I'll try that variation too. Thanks

    I've thought of another possibility. Is it possible it would take some time for the rewrite rule to "activate"? Like it would take some time for it to register with the server that there is a new rule it needs to follow?
    Last edited by fl00d; 11-27-2007 at 02:51 AM. Reason: Expanded idea

  • #9
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,642
    Thanks
    2
    Thanked 405 Times in 397 Posts
    No, as soon as you upload it, it should take effect.

  • #10
    Regular Coder
    Join Date
    Mar 2007
    Location
    Quebec
    Posts
    261
    Thanks
    6
    Thanked 7 Times in 7 Posts
    I fixed it!
    Turns out it didn't like using the starting name ^new. I don't know why but anyways...it's all good now.

    Thanks for the help
    Last edited by fl00d; 11-27-2007 at 01:40 PM.


  •  

    Posting Permissions

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