gvp16 Posted February 14, 2010 Share Posted February 14, 2010 Hi, im looking to make the URLs for pages more seo friendly, i currently have something like this www.mysite.com/content/index.php?page=56543 and would like to make it look like this: www.mysite.com/content/56543/this_is_todays_news So the title of the page/article/information is in the url. Ive seen it done before and cant quite figure out how its done. Im looking for a nudge in the right direction. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/191998-url-titles/ Share on other sites More sharing options...
The Little Guy Posted February 14, 2010 Share Posted February 14, 2010 Try adding this to your htaccess file: Options +FollowSymlinks RewriteEngine on RewriteBase / RewriteRule /content/(.*)/this_is_todays_news$ content/index.php?page=$1 [nc] Quote Link to comment https://forums.phpfreaks.com/topic/191998-url-titles/#findComment-1011976 Share on other sites More sharing options...
gvp16 Posted February 14, 2010 Author Share Posted February 14, 2010 Hi, thanks for the quick reply, im guessing its not as simple as just putting that code into the htaccess. im new to htacess so im not really sure what im doing, but im guessing that I have to set up my links slightly different and then that code rewrites them to make them look better? Quote Link to comment https://forums.phpfreaks.com/topic/191998-url-titles/#findComment-1011978 Share on other sites More sharing options...
The Little Guy Posted February 14, 2010 Share Posted February 14, 2010 you will have to rewrite all the links to look like: www.mysite.com/content/#/this_is_todays_news Quote Link to comment https://forums.phpfreaks.com/topic/191998-url-titles/#findComment-1011979 Share on other sites More sharing options...
gvp16 Posted February 14, 2010 Author Share Posted February 14, 2010 thanks for that, ive got it working where www.mysite.com/page/about goes to www.mysite.com/index.php?page=about but how i do it when a real directory is involved? eg www.mysite.com/content/5 would go to www.mysite.com/content/index.php?id=5 Quote Link to comment https://forums.phpfreaks.com/topic/191998-url-titles/#findComment-1012125 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.