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 5 of 5
  1. #1
    Regular Coder
    Join Date
    Aug 2009
    Posts
    131
    Thanks
    28
    Thanked 7 Times in 7 Posts

    URL rewrite improvement

    Hello.

    I've read a bit about mod_rewrite to modify my URLs. I'm doing something similar to:

    Code:
    Rewrite on, bla bla
    
    RewriteRule ^page/bla$ pages/bla.php
    This works when going to www.mysite.com/page/bla - however, adding another slash in the end doesn't work.

    How can I make it work either way if I add a slash or not? Or - automatically remove the extra slash from the URL, if it is supplied.

    Thanks

  2. #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,964
    Thanks
    164
    Thanked 2,236 Times in 2,223 Posts
    Code:
    RewriteRule ^page/bla$ pages/bla.php
    You may indicate 0 or more occurrence of a pattern using the wildcard ?
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  3. #3
    Regular Coder
    Join Date
    Aug 2009
    Posts
    131
    Thanks
    28
    Thanked 7 Times in 7 Posts
    Quote Originally Posted by abduraooft View Post
    Code:
    RewriteRule ^page/bla$ pages/bla.php
    You may indicate 0 or more occurrence of a pattern using the wildcard ?
    Hey, sorry for the slow answer.

    Could you please explain more briefly and perhaps give me an example of that?

    Thanks.

  4. #4
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,964
    Thanks
    164
    Thanked 2,236 Times in 2,223 Posts
    Try
    Code:
    RewriteRule ^page/bla/?$ pages/bla.php
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  5. Users who have thanked abduraooft for this post:

    [vengeance] (10-26-2009)

  6. #5
    Regular Coder
    Join Date
    Aug 2009
    Posts
    131
    Thanks
    28
    Thanked 7 Times in 7 Posts
    Quote Originally Posted by abduraooft View Post
    Try
    Code:
    RewriteRule ^page/bla/?$ pages/bla.php
    Ah, I see what you mean now.
    Yeah, that did the job, thanks. I'll read more about it another time too.


 

Posting Permissions

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