vbnullchar Posted September 19, 2007 Share Posted September 19, 2007 hello.. how can i rewrite this urls with multiple parameters: http://localhost/purchase/index.php?page=edititem&cat_id=1&item_id=2... etc to http://localhost/purchase/edititem/1/2 i have a exiting rewrite this works without url parameters : RewriteRule ^([A-Za-z0-9-]+)/?$ index.php?page=$1 [QSA,L] thanks, Quote Link to comment https://forums.phpfreaks.com/topic/69876-url-rewrite-with-multiple-parameter/ Share on other sites More sharing options...
hackerkts Posted September 19, 2007 Share Posted September 19, 2007 RewriteEngine on RewriteRule ^purchase/([a-z]+)/([0-9]+)/([0-9]+)$ purchase/index.php?page=$1&cat_id=$2&item_id=$3 Hope this works. Quote Link to comment https://forums.phpfreaks.com/topic/69876-url-rewrite-with-multiple-parameter/#findComment-351235 Share on other sites More sharing options...
vbnullchar Posted September 20, 2007 Author Share Posted September 20, 2007 what if i have an unknown number of parameters? Quote Link to comment https://forums.phpfreaks.com/topic/69876-url-rewrite-with-multiple-parameter/#findComment-351532 Share on other sites More sharing options...
hackerkts Posted September 20, 2007 Share Posted September 20, 2007 Which parameters you're referring to? page, cat_id or item_id? and please give some examples of unknown number. Quote Link to comment https://forums.phpfreaks.com/topic/69876-url-rewrite-with-multiple-parameter/#findComment-351634 Share on other sites More sharing options...
vbnullchar Posted September 21, 2007 Author Share Posted September 21, 2007 is it possible to remove all the variables in url (item_id,cat_id and others) http://localhost/purchase/index.php?page=edititem&cat_id=1&item_id=2&n_variables=n_values to http://localhost/purchase/edititem/1/2/n1/n2/n3/n4/n.. Quote Link to comment https://forums.phpfreaks.com/topic/69876-url-rewrite-with-multiple-parameter/#findComment-352026 Share on other sites More sharing options...
trq Posted September 21, 2007 Share Posted September 21, 2007 The only way I know of to have an unlimitted number of variables would be to capture them all into one string, then parse that string using php. eg; RewriteRule ^(.*)$ index.php?parms=$1 [L] Then in index.php you would get your entire url (eg; /purchase/edititem/1/2/n1/n2/n3/n4/n) within $_GET['parms']. From there you would need to parse the string yourself using php. This is something simular to what I use within my mvc framework. Quote Link to comment https://forums.phpfreaks.com/topic/69876-url-rewrite-with-multiple-parameter/#findComment-352096 Share on other sites More sharing options...
vbnullchar Posted September 21, 2007 Author Share Posted September 21, 2007 thats what i need.. did you create your own mvc framework? Quote Link to comment https://forums.phpfreaks.com/topic/69876-url-rewrite-with-multiple-parameter/#findComment-352126 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.