4

I just installed a friends blog on my LAMP stack, which has mod_rewrite enabled (I'm using it for clean URLs on my Drupal installs on the same server). For some reason, WordPress (3.0.3) isn't recognizing that mod_rewrite is enabled. In the Permalinks menu it's displaying options for PATHINFO permalinks (with index.php preceding the url string).

My fix for now was to just use the Custom Structure field and input what I wanted less the index.php part WordPress seems intent on inserting, which works but I'd like to get an actual fix for this in place.

Is this a 3.0.3 anomaly? I haven't had much time to investigate my server configuration, but any guidance would be much appreciated.

6
  • If you remove the /index.php/ from the permalink definition on the Permalinks page does the site still work? Or will WordPress only work with /index.php/ defined?
    – EAMann
    Commented Dec 13, 2010 at 22:50
  • 1
    It works without index.php just fine, my problem is that I'm not going to be managing this site and I would like the options on the Permalinks to show actual "Pretty" urls instead of this crap.
    – bhamrick
    Commented Dec 13, 2010 at 22:52
  • 2
    The only time it'll automatically add 'index.php' to a permalink is if $is_apache returns false. I think we need more information about the configuration on your server. Commented Dec 13, 2010 at 23:14
  • phpxref.ftwr.co.uk/wordpress/nav.html?wp-admin/… In case you wish to see where WordPress decides when to add index.php Commented Dec 13, 2010 at 23:16
  • 1
    The output of $_SERVER['SERVER_SOFTWARE'] is WebServerX, but it's definitely running Apache. This is a shared server at Surpass Hosting.
    – bhamrick
    Commented Dec 13, 2010 at 23:24

2 Answers 2

5

The output of $_SERVER['SERVER_SOFTWARE'] is WebServerX

That looks like your problem - check out this line in wp-includes/vars.php:

/**
 * Whether the server software is Apache or something else
 * @global bool $is_apache
 */
$is_apache = (strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') !== false || strpos($_SERVER['SERVER_SOFTWARE'], 'LiteSpeed') !== false);

I think you'll need to override this variable manually, either in a plugin or your theme's functions.php:

global $is_apache;
$is_apache = true;

Props to @John P Bloch:

The only time it'll automatically add 'index.php' to a permalink is if $is_apache returns false.

2
  • 1
    Perfect, thanks, I was trying to set $_SERVER['SERVER_SOFTWARE'] to "Apache/2.2.11" but that wasn't working. This did.
    – bhamrick
    Commented Dec 14, 2010 at 18:37
  • @bhamrick: to set $_SERVER['SERVER_SOFTWARE'] it was already to late. So you needed to change the resulting value ($GLOBALS['is_apache']) then. Obviously it was not to late for the important settings while changing it (relatively late) in functions.php. Thanks for providing the info.
    – hakre
    Commented Feb 11, 2011 at 1:13
2

Alternatively you can add the following line of code to your functions.php file:

add_filter( 'got_rewrite', '__return_true', 999 );

We're doing this to make WordPress play well with nginx.

1
  • How bizarre, after upgrading to wordpress 3.6, my permalinks were suddenly all broken and the permalink settings were trying to force an index.php in all the options. For some reason $_SERVER['SERVER_SOFTWARE'] was returning HTTPD. This worked though.
    – waffl
    Commented Aug 7, 2013 at 12:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.