thara Posted June 13, 2012 Share Posted June 13, 2012 everyone.. I need to rewrite this URL http://www.mydomain.com/profiles/tutors/index.php?tutorCode=1255&tutorName=Kasun%20Perera&city=Bandarawela like this http://www.mydomain.com/profiles/tutors/1255/Kasun+Perera.html can anybody help me to do this using Apache’s mod_rewrite feature. any comments are greatly appreciated. Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/264086-url-rewriting-help/ Share on other sites More sharing options...
thara Posted June 14, 2012 Author Share Posted June 14, 2012 this is my original URL http://localhost/tutor_institute/profiles/tutors/index.php?tutorCode=1255&tutorName=Jhon Amarathunga&city=Perth I need to rewrite it like this http://localhost/tutor_institute/profiles/tutors/1255/Perth/Jhon Amarathunga.html here tutor_insitute, profiles and tutors are sub directories in my root directory. index.php page exist in tutors directory and also my htaccess file placed there. I did in my htaccess file like this RewriteEngine on RewriteRule ^/tutor_institute/profiles/tutors/([0-9]+)/([A-Za-z_]+)/([A-Za-z_]+)$ index.php?tutorCode=$1&tutorName=$2&city=$3 [NC] but it is not working.. anybody tell me where I have gone wrong? Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/264086-url-rewriting-help/#findComment-1353808 Share on other sites More sharing options...
requinix Posted June 14, 2012 Share Posted June 14, 2012 You're too restrictive with the name. IMO allow pretty much everything and let your code find out if the name is correct or not. Quote Link to comment https://forums.phpfreaks.com/topic/264086-url-rewriting-help/#findComment-1353820 Share on other sites More sharing options...
thara Posted June 14, 2012 Author Share Posted June 14, 2012 Your answer is completely not clear for me. No idea about IMO.. Can you elaborate this more, actually It will help me to clear this problem... Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/264086-url-rewriting-help/#findComment-1353833 Share on other sites More sharing options...
requinix Posted June 14, 2012 Share Posted June 14, 2012 [A-Za-z_]+ You require that the name have only letters and underscores. That isn't what you want. Change it so that it allows what you want it to allow. Quote Link to comment https://forums.phpfreaks.com/topic/264086-url-rewriting-help/#findComment-1353837 Share on other sites More sharing options...
Jessica Posted June 14, 2012 Share Posted June 14, 2012 No idea about IMO For future reference, that means In My Opinion. (IMHO = same with HONEST). Quote Link to comment https://forums.phpfreaks.com/topic/264086-url-rewriting-help/#findComment-1353845 Share on other sites More sharing options...
thara Posted June 14, 2012 Author Share Posted June 14, 2012 For future reference, that means In My Opinion. (IMHO = same with HONEST). Thanks for it.. [A-Za-z_]+ I change it like this [A-Za-z_-+]+ But still my browser URL is same. it is not changing as I expect. Quote Link to comment https://forums.phpfreaks.com/topic/264086-url-rewriting-help/#findComment-1353852 Share on other sites More sharing options...
Jessica Posted June 14, 2012 Share Posted June 14, 2012 Wait, I think you have this backwards. The purpose of modrewrite it to accept a URL like http://www.mydomain.com/profiles/tutors/1255/Kasun+Perera and translate it to http://localhost/tutor_institute/profiles/tutors/index.php?tutorCode=1255&tutorName=Jhon Amarathunga&city=Perth So that index.php gets run. It does not change the URL in your existing link attributes. Quote Link to comment https://forums.phpfreaks.com/topic/264086-url-rewriting-help/#findComment-1353862 Share on other sites More sharing options...
thara Posted June 15, 2012 Author Share Posted June 15, 2012 Can I rewrite URL in localhost? for 3 days I am trying to rewrite my URL in localhost.. still I cant get it works.. any comments are greatly appreciated. Thank You. Quote Link to comment https://forums.phpfreaks.com/topic/264086-url-rewriting-help/#findComment-1354044 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.