Go Back   FormKaos: Board > General Discussion > Coffee Lounge
FAQ Community Arcade Today's Posts Search

Coffee Lounge Talk amongst other community members.

Reply
 
LinkBack Topic Tools Rate Topic
  #1 (permalink)  
Old Jan 18, 07
disillusionist
 
Join Date: Feb 2006
mekim will become famous soon enough
anyone here good with mod_rewrite?

having a bit of trouble with a rewrite rule, thought i'd see if anyone here has some knowledge of it.

right now i have the following rule:
RewriteRule ^([a-zA-Z0-9_\-]+)-([0-9_]+)/([0-9]+)/?$ index\.php?x=$2&y=$3%{QUERY_STRING} [L]

so the first ([0-9_]+) is mapped to the x variable and the second is mapped to the y variable.

for example:

http://example.com/random_text-10/2/

rewrites to

http://example.com/index.php?x=10&y=2

now, i want to be able to pass along an extra variable or 2 (doesn't matter how many, could be another 10 variables) at the end of the URL like so:

http://example.com/
random_text-10/2/?z=100

or even

http://example.com/
random_text-10/2/?z=100&xx=50&yy=75

those would be the equivalents of

http://example.com/index.php?x=10&y=2&z=100
http://example.com/index.php?x=10&y=2&z=100&xx=50&yy=75


i'm just not too sure how to change this rewrite rule to do what i want, i normally avoid regular expressions like the plague.

(mods, feel free to move if this isn't the right forum)
Reply With Quote
  #2 (permalink)  
Old Jan 18, 07
disillusionist
 
Join Date: Feb 2006
mekim will become famous soon enough
no mod_rewrite wizards out there?
Reply With Quote
  #3 (permalink)  
Old Jan 18, 07
WCG
 
Join Date: Oct 2004
Goodfellow will become famous soon enoughGoodfellow will become famous soon enough
you map the ([0-9_]+)([0-9_]+) with the variable of ttp://example.com/random_text-10/2/?z=100&xx=50&yy=75sdlkflkdsf with the variables &y=$3%{QUERY_STRING} [L] over Y

to prove I know what I'm talking about, here's a pic of me @ work.
Reply With Quote
  #4 (permalink)  
Old Jan 18, 07
disillusionist
 
Join Date: Feb 2006
mekim will become famous soon enough
damn, i knew it was something easy.
Reply With Quote
  #5 (permalink)  
Old Jan 18, 07
WCG
 
Join Date: Oct 2004
Goodfellow will become famous soon enoughGoodfellow will become famous soon enough
Glad I could help.

I just got a pair of octuple focals, I can do 8 mod rewrites at the same time!
Reply With Quote
  #6 (permalink)  
Old Jan 19, 07
Junglist
Guest
 
Quote:
Originally Posted by Goodfellow View Post
you map the ([0-9_]+)([0-9_]+) with the variable of ttp://example.com/random_text-10/2/?z=100&xx=50&yy=75sdlkflkdsf with the variables &y=$3%{QUERY_STRING} [L] over Y

to prove I know what I'm talking about, here's a pic of me @ work.
haha that's fuckin' hilarious!

That picture looks like it's about 20 years old, but I'm pretty sure he's browsing youtube?
Reply With Quote
  #7 (permalink)  
Old Jan 19, 07
www.lazy-rich.com
 
Join Date: Apr 2006
Lazy-Rich is on a distinguished road
hmm, I usually just use a Query String Append [QSA,L] tag in my final rule e.g.

RewriteRule ^([a-zA-Z0-9_\-]+)-([0-9_]+)/([0-9]+)/(.*) index\.php?x=$2&y=$3 [QSA,L]

That should (not tested) add on the z, xx and yyy variables that you have in your URL http://example.com/random_text-10/2/?z=100&xx=50&yy=75

If you always know what those extra variables are and they always exist you could do -

RewriteRule ^([a-zA-Z0-9_\-]+)-([0-9_]+)/([0-9]+)/([a-zA-Z0-9_\-]+)/([a-zA-Z0-9_\-]+)/([a-zA-Z0-9_\-]+)/(.*) index\.php?x=$2&y=$3&z=4&xx=5&zz=6 [QSA,L]

where URL=http://example.com/random_text-10/2/100/50/75/t.html

Hope that helps, Mod rewrite is the most frustrating thing I have ever done, you just have to keep trying different things til it works. Worth the trouble for your SEO though.



Reply With Quote
  #8 (permalink)  
Old Jan 20, 07
disillusionist
 
Join Date: Feb 2006
mekim will become famous soon enough
Quote:
Originally Posted by Lazy-Rich View Post
hmm, I usually just use a Query String Append [QSA,L] tag in my final rule e.g.

RewriteRule ^([a-zA-Z0-9_\-]+)-([0-9_]+)/([0-9]+)/(.*) index\.php?x=$2&y=$3 [QSA,L]

That should (not tested) add on the z, xx and yyy variables that you have in your URL http://example.com/random_text-10/2/?z=100&xx=50&yy=75

If you always know what those extra variables are and they always exist you could do -

RewriteRule ^([a-zA-Z0-9_\-]+)-([0-9_]+)/([0-9]+)/([a-zA-Z0-9_\-]+)/([a-zA-Z0-9_\-]+)/([a-zA-Z0-9_\-]+)/(.*) index\.php?x=$2&y=$3&z=4&xx=5&zz=6 [QSA,L]

where URL=http://example.com/random_text-10/2/100/50/75/t.html

Hope that helps, Mod rewrite is the most frustrating thing I have ever done, you just have to keep trying different things til it works. Worth the trouble for your SEO though.
thanks man! the extra variables aren't going to be appended to every url (they're mainly passed along when lists are being sorted by different values) so i'll test out that first one you posted.
Reply With Quote
Reply


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
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump


All times are GMT -7. The time now is 03:02 AM.


Forum software by vBulletin
Circa 2000 FNK.CA