|
Coffee Lounge Talk amongst other community members. |
|
LinkBack | Topic Tools | Rate Topic |
|
|||
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) |
|
|||
Quote:
That picture looks like it's about 20 years old, but I'm pretty sure he's browsing youtube? |
|
|||
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. |
|
|||
Quote:
|