How would I do this?
A:
Try this mod_rewrite rule:
RewriteEngine on
RewriteCond %{QUERY_STRING} ^a=(\d+)&b=(\d+)$
RewriteRule ^index\.php$ %1/%2
This will rewrite a request of /index.php?a=6&b=3
internally to /6/3
.
And if you rather want the other way round:
RewriteEngine on
RewriteRule ^(\d+)/(\d+)$ index.php?a=$1&b=$2
This will rewrite a request of /6/3
internally to /index.php?a=6&b=3
.
Gumbo
2010-04-09 08:32:16
Note that you need to have `mod_rewrite` enabled on you Apache installation. It's not turned on per default, but it is a common module.
troelskn
2010-04-09 08:36:44
Nice, thanks! :D
Johannes Jensen
2010-04-09 08:42:40
How would I make it so that it ONLY does it if I'm on index.php? Like, so it won't mess up my directories?
Johannes Jensen
2010-04-09 08:44:33
Which one are you using, the first or the second?
El Yobo
2010-04-09 09:16:30
El Yobo
2010-04-09 09:17:48
For the second, you would have to change the address slightly, so instead of requesting /6/3 you would request /some_unique_name/6/3, where some_unique_name is some appropriate name that doesn't match your directories. The condition would then be "RewriteCond %{REQUEST_URI} ^/some_unique_name/(\d+)/(\d+)$"
El Yobo
2010-04-09 09:20:08
Ah, thanks El Yobo. xD !
Johannes Jensen
2010-04-09 11:15:44