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
    New to the CF scene
    Join Date
    Jul 2009
    Location
    Rotterdam, The Netherlands
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Macintosh mod rewrite based on first letter

    Hi all,

    I need some help with the following:

    I'm building some sort of a glossary in WordPress. It's working fine, I'd just like to rewrite the URLs of the glossary posts to the appropriate glossary page.

    for example the post http://myurl.com/category-glossary/example1
    should redirect to the page http://myurl.com/glossary/?snap=E

    http://myurl.com/category-glossary/anotherexample
    should go to http://myurl.com/glossary/?snap=A

    do basically i would like to redirect based on the first letter of a glossary post. Is there anyone who could point me in the right direction?

    Thanks!

  • #2
    Regular Coder ninnypants's Avatar
    Join Date
    Apr 2008
    Location
    Utah
    Posts
    504
    Thanks
    10
    Thanked 47 Times in 47 Posts
    try putting this in your .htaccess
    Code:
    RewriteRule (.*glossary/)([^/])/? $1?snap=$2 [L, R=301]
    I'm using something similar to this in one of my projects

  • #3
    New to the CF scene
    Join Date
    Jul 2009
    Location
    Rotterdam, The Netherlands
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for your reply ninnypants,

    it's not working quite yet, I get a 500 internal server error. I have also made a mistake in my initial request..

    the original URL is fairly similar to the resulting URL, it should be:

    http://myurl.com/glossary/example1/ should redirect to the page http://myurl.com/glossary/?snap=E

    and http://myurl.com/glossary/anotherexample/ should go to http://myurl.com/glossary/?snap=A

    Could you please take a look at it again? Thanks a million!

  • #4
    Regular Coder ninnypants's Avatar
    Join Date
    Apr 2008
    Location
    Utah
    Posts
    504
    Thanks
    10
    Thanked 47 Times in 47 Posts
    The 500 error is probably from something else in your .htaccess file. Also it's impossible to tell what the first letter is and capitalize it unless you create a RewriteRule for every letter in the alphabet.

  • #5
    New to the CF scene
    Join Date
    Jul 2009
    Location
    Rotterdam, The Netherlands
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ok, thanks for replying, i'll check my .htaccess


  •  

    Tags for this Thread

    Posting Permissions

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