views:

53

answers:

2

I've recently installed Wordpress and can't seem to get the website to display friendly URLs no matter what settings I use inside the Dashboard or in an .htaccess file. I've tried numerous versions of Wordpress and still can't achieve what I need, despite succeeding on hosts other than Concentric/XO, any idea why?

A: 

Ask them whether they have mod_rewrite enabled.

To find out yourself, try adding a .htaccess file containing gibberish first:

sadölkasdfksdakföasldfg

if putting that onto the webspace, and then trying to access any page on it results in a 500 error, htaccess files get parsed. Then try adding a "real" .htaccess file:

RewriteEngine On

if that works without a 500, then URL rewriting should be turned on.

Pekka
+1  A: 

Follow these steps before you attempt to install WordPress for the first time. If you have already installed it, start over.

To get Permalinks working you need to create a .htaccess file, WordPress can't do this automatically on this host. Here is what the basic .htaccess file should look like:

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

Make sure you create this file using an editor that allows for unix formatting (like PSPad, or VIM, Textmate, etc.), using notepad will give you a parsing error - it has something to do with invisible end of file characters(CLRF). Make sure the last rule has a hard return after it, it's required. .htaccess files are cached for up to 15 minutes so you may have to wait for it to kick in.

Next you'll need to edit your wp-settings.php file so open that up in your editor. Add the following code right above the closing ?> php tag:

if(isset($_REQUEST['q'])) {
$_SERVER['REQUEST_URI'] = "/" . $_REQUEST["q"];
}else{
if (empty($_SERVER['QUERY_STRING'])) {
$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'];
       } else {
$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . "?" .
$_SERVER['QUERY_STRING'];
       }
}

If someone can write that block of code more cleanly feel free, I'm not an expert PHP programmer.

Once that block of code is in place you can proceed to run the install.

Now that WordPress is installed you'll have to do one more thing before you can start blogging:

Create a new file called: disable-canonical-redirects.php and upload it to the wp-content/plugins directory.

Drop this block of code into that file:

<?php
    /*
    Plugin Name: Disable Canonical URL Redirection
    Description: Disables the "Canonical URL Redirect" features of WordPress 2.3 and above.
    Version: 1.0
    Author: Mark Jaquith
    Author URI: http://markjaquith.com/
    */

    remove_filter('template_redirect', 'redirect_canonical');

?>

Now you need to enable that plugin, go to the Admin login page: example.com/wp-login

Enable the plugin you created. That's it, you're on a horse.

ccheney
Wow, that took a few minutes but it worked like a charm.
harkmylord