← Moon | Back from the Grave →
Pretty WordPress permalinks without PATHINFO
For a client I was installing WordPress, when I found out that their webserver doesn’t support PATHINFO, which WordPress needs for its pretty permalinks.
I worked around this problem by changing the .htaccess rewrite rule so that the path is supplied as normal GET parameter:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* /index.php?path=$0 [L]
</IfModule>
Then in WordPress’ index.php I set the REQUEST_URI and PATHINFO to what they should have been:
if (preg_match('/(.*)?path=(.*)/', $_SERVER['REQUEST_URI'], $matches)) {
$_SERVER['REQUEST_URI'] = $matches[1] . '/' . $matches[2];
$_SERVER['PATH_INFO'] = '/' . $matches[2];
}
And voilà! Pretty permalinks without PATHINFO.
Edit: WordPress doesn’t approve of custom .htaccess files and tries to overwrite them everytime the admin panel (or certain pages of it) is loaded. To fix this problem, make your .htaccess file read-only.
Comments
Great… but what webserver doesn’t support PATH_INFO?
Lycos webservers, apparently! I’ve sent them two emails about it, but all they will say is:
“Wij delen u mede dat het niet mogelijk is om de PATHINFO functie aan te zetten, omdat u een Shared Hosting gebruikt.
Met een Shared Hosting hebt u beperkte mogelijkheden om uw website aan te passen.”
Hi Martijn.
I lost that website that had your address on it.
I would like to have it. I felt like writing you today.
I like letters. We need to keep in touch.
-Dana
tried it with my lycos hosting but still does not seem to work…are there any other options apart from accepting this problem and using the default permalinks?
great thing if it worked with you and i so wish that my frend didnt use lycos..
Thanks a lot, it works fine on Lycos
I didnt get it to work:
Warning: Division by zero in /data/members/paid/a/d/XXXXX.nl/htdocs/www/index.php on line 6Warning: Division by zero in /data/members/paid/a/d/XXXXX.nl/htdocs/www/index.php on line 7
hmm apparantly I had to put the lines in the index.php in front of the
/* Short and sweet */
define(‘WP_USE_THEMES’, true);
require(‘./wp-blog-header.php’);
Leave a comment!
Martijn loves to receive comments! Add yours by filling out the fields below.
