Forum Moderators: phranque
Using RedirectMatch.
RedirectMatch /pages/(.*)/index\.php [example\.com...]
I also want it to work if index.php is not specified, like this:
[example.com...]
RedirectMatch /pages/(.*)/index\.php [example.com...]
RedirectMatch /pages/(.*)/$ [example.com...]
In theory anyway.
At the moment xx can be anything. If you know you're only going to have numerals in there for example you can change (.*) to be ([0-9]*)
RedirectMatch /pages/([^/]+)(/?¦index\.php)?$ http://www.example.com/?page=$1
http://www.example.com/%3fpage=xx
Yay escaping. =)
If that became an issue, you could just use mod_rewrite (assuming such an option is available):
RewriteEngine on
RewriteRule ^/pages/([^/]+)(/?¦index\.php)?$ http://www.example.com/?page=$1 [L,R]
I /think/ that regex covers all the bases, although I'm a bit fried right now. =)
Oh, an jetboy's right (well, almost); if the page is always going to be numeric, something like this:
RedirectMatch /pages/([0-9]+)(/?¦index\.php)?$ [example.com...]
You want [0-9]+ and not [0-9]*, because [0-9]* would match on an empty string (the '*' matches "zero or more occurrences of the preceding atom").