Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question
    
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 Dec 13 '10 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 Dec 13 '10 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. –  John P Bloch Dec 13 '10 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 –  John P Bloch Dec 13 '10 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 Dec 13 '10 at 23:24
show 1 more comment

2 Answers 2

up vote 4 down vote accepted

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.

share|improve this answer
1  
Perfect, thanks, I was trying to set $_SERVER['SERVER_SOFTWARE'] to "Apache/2.2.11" but that wasn't working. This did. –  bhamrick Dec 14 '10 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 Feb 11 '11 at 1:13
add comment

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.

share|improve this answer
    
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 Aug 7 '13 at 12:50
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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