Go Back   CodingForums.com > :: Server side development > Apache configuration

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-07-2009, 02:31 PM   PM User | #1
Level Level
New to the CF scene

 
Join Date: Jul 2009
Location: Rotterdam, The Netherlands
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Level Level is an unknown quantity at this point
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!
Level Level is offline   Reply With Quote
Old 07-08-2009, 04:44 AM   PM User | #2
ninnypants
Regular Coder

 
ninnypants's Avatar
 
Join Date: Apr 2008
Location: Utah
Posts: 504
Thanks: 10
Thanked 47 Times in 47 Posts
ninnypants is an unknown quantity at this point
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
ninnypants is offline   Reply With Quote
Old 07-08-2009, 09:19 AM   PM User | #3
Level Level
New to the CF scene

 
Join Date: Jul 2009
Location: Rotterdam, The Netherlands
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Level Level is an unknown quantity at this point
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!
Level Level is offline   Reply With Quote
Old 07-09-2009, 04:26 AM   PM User | #4
ninnypants
Regular Coder

 
ninnypants's Avatar
 
Join Date: Apr 2008
Location: Utah
Posts: 504
Thanks: 10
Thanked 47 Times in 47 Posts
ninnypants is an unknown quantity at this point
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.
ninnypants is offline   Reply With Quote
Old 07-09-2009, 07:28 AM   PM User | #5
Level Level
New to the CF scene

 
Join Date: Jul 2009
Location: Rotterdam, The Netherlands
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Level Level is an unknown quantity at this point
ok, thanks for replying, i'll check my .htaccess
Level Level is offline   Reply With Quote
Reply

Bookmarks

Tags
.htaccess, first letter, modrewrite

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:57 PM.


Advertisement
Log in to turn off these ads.