scrubbicus Posted November 29, 2009 Share Posted November 29, 2009 Hey, I'm wondering how to go about creating and using these types of URLs. I'm presuming it's PHP that does this? I see them on Wordpress and Joomla and such but I've been trying to learn exactly how to create these types of URLs. Does anyone have an article or tutorial to start off to get going? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/183256-seo-urls/ Share on other sites More sharing options...
Alex Posted November 29, 2009 Share Posted November 29, 2009 This is done using mod_rewrite. Here's a decent tutorial on it, http://articles.sitepoint.com/article/guide-url-rewriting Quote Link to comment https://forums.phpfreaks.com/topic/183256-seo-urls/#findComment-967205 Share on other sites More sharing options...
keldorn Posted November 29, 2009 Share Posted November 29, 2009 Thing about that is your web application need to have a "seo url" slug, stored in the database alongside the ID. The slug is a formated version of the title of your page, so say your page is. "Foo widget and Acme Widgets" , the seo version would be "foo-widget-acme-widgets" , that would be stored in the DB too. When you create your pages, you take the seo url slug and put into the links on your site programmatically. example/articles/foo-widget-acme-widgets/ .htaccess grabs the "foo-widget-acme-widgets", sends it to the article.php file, article.php?page=foo-widget-acme-widgets , "foo-widget-acme-widgets" is sent into the db and to retrieve the content where the row has "foo-widget-acme-widgets". Quote Link to comment https://forums.phpfreaks.com/topic/183256-seo-urls/#findComment-967231 Share on other sites More sharing options...
keldorn Posted November 29, 2009 Share Posted November 29, 2009 btw if you dont have a seo url slug, sometimes in a web application a design change like that might be too late. You can use just the auto-incrementing ID of the row that the article, product or whatever is in. So instead of article.php?id=10 You could do this. /article/10 .htaccess just grabs the "10" and does the same thing, sends it to your script and your script finds the row where id is 10. Quote Link to comment https://forums.phpfreaks.com/topic/183256-seo-urls/#findComment-967239 Share on other sites More sharing options...
dragon_sa Posted November 29, 2009 Share Posted November 29, 2009 mod rewrite for htaccess no database entry needed simply code your links as html links and let htaccess convert them to the real pages for your applications eg htaccess Options +FollowSymLinks RewriteEngine On RewriteRule ^([^/-]+).html$ /$1.php [R=301,L] so you would make your link products.html for example and that htaccess will convert that to product.php, it is also possible to pass variables to the pages with this method aswell. Quote Link to comment https://forums.phpfreaks.com/topic/183256-seo-urls/#findComment-967242 Share on other sites More sharing options...
keldorn Posted November 29, 2009 Share Posted November 29, 2009 mod rewrite for htaccess no database entry needed Well you do and you dont, take this for example, http://www.iwantthathair.com/body-lotions-s/47.htm The /body-lotions-s/ is made probably programmtically, the 47 is the ID in the table, but that generates a bad problem, since /body-lotions-s/ is not actually checked in the db along with id, You can do this hxxp://www.iwantthathair.com/lollolololololollolololololololololol-s/47.htm (not linked so a search bot doesn't follow this) Malicious things can happen, if someone can generate infinite urls to a page. For example I could generat all kinds of urls to pointing your page, then spam them everywhere and you get your site penalized for duplicate content. Quote Link to comment https://forums.phpfreaks.com/topic/183256-seo-urls/#findComment-967270 Share on other sites More sharing options...
dragon_sa Posted November 29, 2009 Share Posted November 29, 2009 more page specific rules can be made that was a general example likewise:- 1 variable RewriteRule ^catalog-([^/-]+).html$ /catalogs.php?colID=$1 [NC] 2 variables RewriteRule ^products-([^/-]+)-([^/-]+).html$ /products.php?ID=$1&catID=$2 [NC] and so on Quote Link to comment https://forums.phpfreaks.com/topic/183256-seo-urls/#findComment-967289 Share on other sites More sharing options...
scrubbicus Posted December 17, 2009 Author Share Posted December 17, 2009 I can't seem to get it working. I was following the tutorial and I got into the http.conf and was able to #LoadModule rewrite_module modules/mod_rewrite.so remove the # but I couldn't find the #AddModule, but I tried restarting my apache anyway and went on with the tutorial but not working so I figured that was majorly important. Quote Link to comment https://forums.phpfreaks.com/topic/183256-seo-urls/#findComment-978951 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.