beboo002 Posted September 7, 2007 Share Posted September 7, 2007 hello all how i am rewrite url in php. i hav no idea about url rewritting. i am createing adynamic site and my url look like http://localhost/adminajax/home1.php?sub_cat_id=1 now i need url look like this http://localhost/adminajax/home1.php/animation automation Quote Link to comment https://forums.phpfreaks.com/topic/68320-how-to-rewrite-url-in-php/ Share on other sites More sharing options...
gerkintrigg Posted September 7, 2007 Share Posted September 7, 2007 you need to look into mod rewrite. I'm not sure how to do it either, but i think it's something in the PHP ini file. I'll be watching this topic to see how you get on and whether anyone has any hints. I hope this helps. Quote Link to comment https://forums.phpfreaks.com/topic/68320-how-to-rewrite-url-in-php/#findComment-343531 Share on other sites More sharing options...
hackerkts Posted September 7, 2007 Share Posted September 7, 2007 Wrong section, anyway.. Where you got animation automation from? The name of sub_cat_id 1? Quote Link to comment https://forums.phpfreaks.com/topic/68320-how-to-rewrite-url-in-php/#findComment-343546 Share on other sites More sharing options...
beboo002 Posted September 7, 2007 Author Share Posted September 7, 2007 wht are u saying hackerkts i dont understand ??? Wrong section, anyway.. Where you got animation automation from? The name of sub_cat_id 1? Quote Link to comment https://forums.phpfreaks.com/topic/68320-how-to-rewrite-url-in-php/#findComment-343553 Share on other sites More sharing options...
noidtluom Posted September 7, 2007 Share Posted September 7, 2007 Apache I think. Go into your .htaccess and add: RewriteEngine on RewriteBase / Then for every page add: ReWriteRule ^animationautomation/$ home1.php?sub_cat_id=1 ReWriteRule ^animationautomation$ home1.php?sub_cat_id=1 In case you might want to send variables over the URL you might want to look at this code as well, it's pretty self explanatory: By the way, the below code is only for sending integer variables. This is useful for pages which you want to limit the variable. ReWriteRule ^mypage/([0-9]+)/$ index.php?p=mypage&id=$1 ReWriteRule ^mypage/([0-9]+)$ index.php?p=mypage&id=$1 So if you want to send two variables for example you can try: ReWriteRule ^mypage/([0-9]+)/([0-9]+)/$ index.php?p=mypage&id=$1&foo=$2 ReWriteRule ^mypage/([0-9]+)/([0-9]+)$ index.php?p=mypage&id=$1&foo=$2 And so 3 variables, go to $3, and so forth. For others you might want to use "(.*)" (without quotes). Sorry if I made a mistake (to those professionals) feel free to correct me. I hope I didn't misunderstand your question. Quote Link to comment https://forums.phpfreaks.com/topic/68320-how-to-rewrite-url-in-php/#findComment-343556 Share on other sites More sharing options...
xyn Posted September 7, 2007 Share Posted September 7, 2007 I would suggest adding [L] at the end of each line to tell apache to stop matching if a match is found this prevents 500 errors. Quote Link to comment https://forums.phpfreaks.com/topic/68320-how-to-rewrite-url-in-php/#findComment-343561 Share on other sites More sharing options...
ToonMariner Posted September 7, 2007 Share Posted September 7, 2007 http://www.alistapart.com/articles/succeed Quote Link to comment https://forums.phpfreaks.com/topic/68320-how-to-rewrite-url-in-php/#findComment-343597 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.