Jagarm Posted March 10, 2009 Share Posted March 10, 2009 Hello all, I currently have url writing on my site, it takes index.php?action=something into host.com/something. Everything is good there, now i have some sites that requires me to pass additional queries to the script such as follow: index.php?action=movies&page=2. What I'm trying to do is have it like this host.com/something/2 So far I have the following and I've been trying for days but no luck in doing that. Options +FollowSymlinks RewriteEngine on RewriteCond %{SCRIPT_FILENAME} !-f RewriteCond %{SCRIPT_FILENAME} !-d RewriteRule ^(.*)$ /index.php?action=$1 RewriteRule ^(.*)/(.*)$ index.php?action=$1&page=$2 I don't know what I am doing wrong there, but I would appreciate some help. As you may know not all the time it will need the page string but sometimes so I tried to make it optional as follow: RewriteRule ^(.*)(/(.*))?$ index.php?action=$1&page=$3 but it doesn't work. I would appreciate any help. Also is it possible to automatically based on the htaccess to change it from index.php?action=movies into /movies or /movies/34 Thanks, Quote Link to comment https://forums.phpfreaks.com/topic/148724-solved-url-rewriting-issues/ Share on other sites More sharing options...
Jagarm Posted March 10, 2009 Author Share Posted March 10, 2009 I'm still trying to get this to work, so far I have the following code Options +FollowSymlinks RewriteEngine on RewriteCond %{SCRIPT_FILENAME} !-f RewriteCond %{SCRIPT_FILENAME} !-d RewriteRule ^(.*)(/(.*))?$ index.php?display=$1&n=$3 [QSA] This works if the &n is specified even though I made it optional that is if its: http://www.beta.berwari.net/index.php?display=movies&n=20 the display argument will contain "music,movies,links,contact" so only for movies there will be the &n argument specified that is for pagination page number. Please let me know if anything is not clear, I really need help with this, since i"m been trying for days with no luck. Thanks again Quote Link to comment https://forums.phpfreaks.com/topic/148724-solved-url-rewriting-issues/#findComment-781411 Share on other sites More sharing options...
Jagarm Posted March 12, 2009 Author Share Posted March 12, 2009 This is what I was looking for and thanks to http://www.workingwith.me.uk/blog/software/open_source/apache/mod_rewriting_an_entire_site I found the way, this is how I done it, in case somebody like me is trying to search for something simlar Options +FollowSymlinks RewriteEngine on RewriteRule ^([^/\.]+)/?$ /index.php?display=$1 [L] RewriteRule ^([^/\.]+)/([^/\.]+)/?$ /index.php?display=$1&n=$2 [L] Thanks to those who looked at my post Quote Link to comment https://forums.phpfreaks.com/topic/148724-solved-url-rewriting-issues/#findComment-782683 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.