Yahoo hosting, no htaccess, and permalinks
January 21, 2009 @ 3:08pm
by Rob Sanchez
So everyone wants clean permalinks these days; those search engine friendly URLs are everywhere (even on our own site!), and made ubiquitous by Wordpress and other CMSes. The usual technique is to use Apache’s mod_rewrite module and an htaccess file to re-write the URLs (see here). But what if you can’t use an htaccess file? Well, I found out recently that Yahoo Small Business hosting does not allow htaccess files, at all, and I had to find a solution for that.
The solution for me? PATH_INFO, an environment variable in Apache, which is basically extra “information” at the end of a file path/URL. So if you have a URL like “www.xyz.com/index.php/permalink/” the PATH_INFO would be “/permalink/”. In PHP, it’s available in the $_SERVER global:
<?php
$path_info = explode('/', $_SERVER['PATH_INFO']);
// start parsing $path_info however you see fit
?>
Now, we already had a custom engine for using handling the mod_rewrite output, and I was able to use that parsed URL data and put it into our system. And have some nice-looking permalinks. There was a small compromise in having that extra “/index.php” in the URL, but I think it is still worth doing and better than no clean permalinks at all.
Tags
Apache, htaccess, mod_rewrite, path_info, permalinks, PHP, Yahoo






