irkevin Posted March 18, 2009 Share Posted March 18, 2009 Hi everyone, I need some help to understand how preg_replace work.. Right now, i have a link which is dynamic, like so http://www.mu-anime.com/index.php?page=CompletedSeries&id=1 I want to use preg_replace to convert it like so http://www.mu-anime.com/completed/1.html I used .htaccess, but now i have to convert the link on my website also and have no idea how to start .. Any help plz? Quote Link to comment https://forums.phpfreaks.com/topic/149994-help-with-preg_replace/ Share on other sites More sharing options...
drisate Posted March 18, 2009 Share Posted March 18, 2009 I dont see why you would need to use preg_replace for that. Can you explain in more details what your trying to do? Quote Link to comment https://forums.phpfreaks.com/topic/149994-help-with-preg_replace/#findComment-787738 Share on other sites More sharing options...
irkevin Posted March 18, 2009 Author Share Posted March 18, 2009 Well, what do you recommend to use for doing this? I'm trying to make my links more friendly for google.. SEF i supose. I've been able to use htaccess to convert the links from dynamic to static.. but now, i have to convert them on my website also so that people can access the static one. . Do you get it now? Quote Link to comment https://forums.phpfreaks.com/topic/149994-help-with-preg_replace/#findComment-787745 Share on other sites More sharing options...
irkevin Posted March 18, 2009 Author Share Posted March 18, 2009 Bump ..no one? Quote Link to comment https://forums.phpfreaks.com/topic/149994-help-with-preg_replace/#findComment-787794 Share on other sites More sharing options...
Andy-H Posted March 18, 2009 Share Posted March 18, 2009 I think you mean regular expressions and mod_rewrite? Quote Link to comment https://forums.phpfreaks.com/topic/149994-help-with-preg_replace/#findComment-787796 Share on other sites More sharing options...
Andy-H Posted March 18, 2009 Share Posted March 18, 2009 Options +FollowSymLinks RewriteEngine on RewriteRule ^(.*)/(.*).html$ /index.php?page=$1&id=$2 [NC] That will re-write:- http://www.mu-anime.com/index.php?page=CompletedSeries&id=1 to http://www.mu-anime.com/CompletedSeries/1.html [NC] = No Case (Case Insensitive) Quote Link to comment https://forums.phpfreaks.com/topic/149994-help-with-preg_replace/#findComment-787800 Share on other sites More sharing options...
irkevin Posted March 18, 2009 Author Share Posted March 18, 2009 thars correct.. but i also need to put them that way on my website if i want users to navigate mu site using static urls.. how do i do this when having stuff coming from database? there must be a way to do this in php also. Quote Link to comment https://forums.phpfreaks.com/topic/149994-help-with-preg_replace/#findComment-787815 Share on other sites More sharing options...
Andy-H Posted March 18, 2009 Share Posted March 18, 2009 have you looked into output buffering? http://php.net/ob_start Quote Link to comment https://forums.phpfreaks.com/topic/149994-help-with-preg_replace/#findComment-787824 Share on other sites More sharing options...
irkevin Posted March 18, 2009 Author Share Posted March 18, 2009 ob_start..? well i dont think it would work with that.. any more suggestion? i heard it could be use with preg_replace, don't know if it's true.. hope someone has the answer to this Quote Link to comment https://forums.phpfreaks.com/topic/149994-help-with-preg_replace/#findComment-787828 Share on other sites More sharing options...
irkevin Posted March 19, 2009 Author Share Posted March 19, 2009 bump.. no one to help? Quote Link to comment https://forums.phpfreaks.com/topic/149994-help-with-preg_replace/#findComment-788296 Share on other sites More sharing options...
irkevin Posted March 19, 2009 Author Share Posted March 19, 2009 still no one :S Quote Link to comment https://forums.phpfreaks.com/topic/149994-help-with-preg_replace/#findComment-788778 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.