I have the following code:
RewriteEngine On
RewriteRule ^user/([0-9]+)/([0-9]+)/?$ template.php?user_id=$1&slide=$2 [NC,L,QSA]
So when I go to http://www.mydomain.com/user/7/1 it is working, and pulling from http://www.mydomain.com/template.php?user_id=7&slide=1
Now my question is, how do I get the slide variable to be optional. I want it to work if someone will type in /user/7/.
In my template.php file I have:
if(!$current_slide) {
header("Location: user/".$user_id."/1");
}
So if I manually go to template.php?user_id=1 it will automatically redirect to /user/7/1/ which is good, it works. But I need to modify my htaccess file so if someone types in /user/7/ it will redirect to /7/1/
Hope that makes sense.
1 Answer