Skip to main content

Posts

Showing posts with the label seo

Setting up SEO-friendly URLs in htaccess/PHP

This is something I feel like I've done dozens of times over the years, and always have to waste some time googling before I figure it out. Maybe next time I'll remember to look here? So, you're writing a custom site, and you need to be able to handle SEO-friendly URLs. You know, the kind where instead of something like "category=my_category&page=233" you the URLs to look more like "/my_category/my_page" Those are called SEO Friendly URLs and really they're also just plain friendlier for people too. They're really kind of a leftover from when a lot static HTML sites were really organized with subdirectories full of HTML files - and Apache will still work like that "out of the box" My usual approach to this has two parts. First, there's a custom .htaccess file in the main site directory, that redirects all requests (that are not for actual files/directories) to index.php Then, in the index.php there's a bit of code ...