craigj1303 Posted April 22, 2014 Share Posted April 22, 2014 Hi There I designed a database driven site some years ago using PHP and HTML. All the site pages are routed through index.php and the content of those pages is determined by the query string in the URL which then triggers PHP includes. I am now at a stage where we have a SEO company who has advised us to make our URL's "SEO friendly". They advise that the best way to do this is using 301 redirects and using the mod_rewrite feature on the Apache Server. I have no experience whatsover with this. What is the best way to go about this? I have googled mod_rewrite etc. but there is so much information I don't know what the best way to proceed is. Below is an example of what I want to achieve across the site: Existing URL: http://www.mycompany.co.uk/index.php?page=show_range&range_id=39 Proposed URL: http://www.mycompany.co.uk/ranges/balmoral If anyone can offer any advice for best practice I would most appreciate, or even a link to a good tutorial that would be great! Thanks in advance, Craig Quote Link to comment https://forums.phpfreaks.com/topic/287940-using-htaccess-to-make-my-urls-seo-friendly/ Share on other sites More sharing options...
bsmither Posted April 22, 2014 Share Posted April 22, 2014 From an application I am very familiar with, this is the approach taken: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !=/favicon.ico RewriteRule ^(.*)\.html?$ index.php?seo_path=$1 [L,QSA] Given: http://www.mycompany.co.uk/ranges/balmoral.html if this isn't an existing file or directory, take ranges/balmoral and set it as the value of the querystring key seo_path. The result will be: http://www.mycompany.co.uk/index.php?seo_path=ranges/balmoral Query a database table holding all the derived paths for the matching item and item_id: | ranges/balmoral | show_range | 39 | Quote Link to comment https://forums.phpfreaks.com/topic/287940-using-htaccess-to-make-my-urls-seo-friendly/#findComment-1476961 Share on other sites More sharing options...
craigj1303 Posted April 22, 2014 Author Share Posted April 22, 2014 Hi, thanks for the advice. Before I go and experiment with that, I have been informed I need to do 301 redirects so not only do the URL's look more frindly, but Google will be aware that they have moved permanently. How do I build that in to the equation? Quote Link to comment https://forums.phpfreaks.com/topic/287940-using-htaccess-to-make-my-urls-seo-friendly/#findComment-1476965 Share on other sites More sharing options...
bsmither Posted April 22, 2014 Share Posted April 22, 2014 I don't know how one would code massive amounts of ReWrite .htaccess statements (the following is only representative and not syntactically correct): if (39) then (balmoral) if ... if ... [301 whatever] The users of the application I mentioned have created a site map, told Google to dump all previous indexed scans, and submitted that sitemap. This is in Google's Webmaster Tools. I have no practical answer on how to implement an immediate solution. Quote Link to comment https://forums.phpfreaks.com/topic/287940-using-htaccess-to-make-my-urls-seo-friendly/#findComment-1477007 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.