Results 1 to 9 of 9

Thread: mod_rewrite (Apache)

  1. #1
    Ah, Mrs. Peel! mike_w's Avatar
    Join Date
    Oct 2003
    Location
    Hertfordshire, England
    Posts
    3,326
    Thanks
    3
    Thanked
    9 times in 7 posts

    mod_rewrite (Apache)

    Right then, I've been playing with mod_rewrite on Apache2. So far, I've managed to convert the simple, nice URLs into the PHP URLs like so:

    Code:
    RewriteRule ^archive/([0-9]+)/([0-9]+)/$ archive.php?m=$2&y=$1
    However, it would also be nice if I could do that in reverse, with the URL changing in the browser. I tried this:

    Code:
    RewriteRule ^archive\.php?m=([0-9]+)&y=([0-9]+)$ archive/$1/$2/ [R]
    But it doesn't seem to do anything. Anybody got any ideas?

    Thanks in advance

    Mike.
    "Well, there was your Uncle Tiberius who died wrapped in cabbage leaves but we assumed that was a freak accident."

  2. #2
    Bigger than Jesus Norky's Avatar
    Join Date
    Feb 2005
    Posts
    1,579
    Thanks
    1
    Thanked
    8 times in 8 posts
    Doesn't work like that, mod_rewrites simply translate the addresses, you'd need to set up some sort of forwarding if you wanted to change the URLs into their shortened form automatically

  3. #3
    Ah, Mrs. Peel! mike_w's Avatar
    Join Date
    Oct 2003
    Location
    Hertfordshire, England
    Posts
    3,326
    Thanks
    3
    Thanked
    9 times in 7 posts
    Quote Originally Posted by Norky
    Doesn't work like that, mod_rewrites simply translate the addresses, you'd need to set up some sort of forwarding if you wanted to change the URLs into their shortened form automatically
    I thought that using [R] can change the URL? It worked when I added slashes to the end of the addresses...

    If I can't do it that way, how should I go about it?

    Thanks!

    Mike.
    "Well, there was your Uncle Tiberius who died wrapped in cabbage leaves but we assumed that was a freak accident."

  4. #4
    Bigger than Jesus Norky's Avatar
    Join Date
    Feb 2005
    Posts
    1,579
    Thanks
    1
    Thanked
    8 times in 8 posts
    Try adding a question mark after the slash

  5. #5
    Ah, Mrs. Peel! mike_w's Avatar
    Join Date
    Oct 2003
    Location
    Hertfordshire, England
    Posts
    3,326
    Thanks
    3
    Thanked
    9 times in 7 posts
    Quote Originally Posted by Norky
    Try adding a question mark after the slash
    Which slash?

    Thanks

    Mike.
    "Well, there was your Uncle Tiberius who died wrapped in cabbage leaves but we assumed that was a freak accident."

  6. #6
    Registered+
    Join Date
    Dec 2005
    Posts
    40
    Thanks
    0
    Thanked
    0 times in 0 posts
    RewriteRule ^archive\.php?m=([0-9]+)&y=([0-9]+)$ archive/$1/$2/ [R]

    You question mark needs escaping

    RewriteRule ^archive\.php\?m=([0-9]+)&y=([0-9]+)$ archive/$1/$2/ [R]

  7. #7
    Ah, Mrs. Peel! mike_w's Avatar
    Join Date
    Oct 2003
    Location
    Hertfordshire, England
    Posts
    3,326
    Thanks
    3
    Thanked
    9 times in 7 posts
    Quote Originally Posted by chud
    RewriteRule ^archive\.php?m=([0-9]+)&y=([0-9]+)$ archive/$1/$2/ [R]

    You question mark needs escaping

    RewriteRule ^archive\.php\?m=([0-9]+)&y=([0-9]+)$ archive/$1/$2/ [R]
    Hmm, still doesn't seem to be working...

    Thanks

    Mike.
    "Well, there was your Uncle Tiberius who died wrapped in cabbage leaves but we assumed that was a freak accident."

  8. #8
    Bigger than Jesus Norky's Avatar
    Join Date
    Feb 2005
    Posts
    1,579
    Thanks
    1
    Thanked
    8 times in 8 posts
    Code:
    RewriteRule ^archive\.php?m=([0-9]+)&y=([0-9]+)$ archive/$1/$2/? [R]
    Is what I meant, it should make it work with or without the trailing /

  9. #9
    Registered+
    Join Date
    Dec 2005
    Posts
    40
    Thanks
    0
    Thanked
    0 times in 0 posts
    Does this change anything?

    RewriteRule ^archive\.php\?m=([0-9]+)&y=([0-9]+)$ archive/$1/$2 [L,R]

    What is the error in the Apache error log (you may need to change loglevel)?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Apache HTTP Web server configuration...
    By joshwa in forum Software
    Replies: 2
    Last Post: 22-06-2005, 02:52 PM
  2. Apache 1.3 Stop port 80 listening
    By ikonia in forum Software
    Replies: 6
    Last Post: 13-04-2005, 05:42 PM
  3. Mono on Apache, any tips?
    By stytagm in forum Software
    Replies: 0
    Last Post: 28-02-2005, 07:48 PM
  4. Apache with IIS
    By yamangman in forum Software
    Replies: 20
    Last Post: 11-02-2005, 01:42 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
  •