PHP-CGI, mod_rewrite and Wordpress

wordpress

#1

Greetings. Just joined DH last week and am bogging down in the mod_rewrite PHP as CGI weirdness. I’ve been trying to transfer a Wordpress setup and everything goes well except I cannot get my .htaccess to redirect properly when I have the WP index page on the root level and all the other files one level down. (This was not a problem on my previous server using PHP as an Apache module.) When I click anywhere from the front page I get a “no input file specified” error.

Disclaimer: I’ve been hesitant to post this question because there are so many references all over the web to mod_rewrite issues with Wordpress running under PHP-CGI, but I’ve looked at all of those that I could find and I still haven’t got the solution. I was planning on re-installing WP with Apache-CGI, but well… that’s no longer an option, is it?

Details:

  1. I used the DH one-click-install for WordPress. Just cuz.

  2. I’ve no problems when the blog and main index.php are in the same folder. However, if I take the path of least resistance and stay with that configuration, lots of links and bookmarks will give people errors. (Unless, I suppose I add rewrite rules kludge to fix that. See #3)

  3. My RegEx skillz are -so very- not mad.
    I’m aware of the many help pages out there for this and mod_rewrite, etc. Alas, I need to get the site up and running now and will only have time for intensive study later. At my current knowledge level, these man pages and tutorials are not helping.

  4. The domain I’m using at the moment is http://testingtheplacebo.com

  5. The current contents of my .htaccess file (very much simplified from the ideal and as suggested by Wordpress itself) are:

[code]# Dreamhost stats fix

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/stats/(.)$ [OR]
RewriteCond %{REQUEST_URI} ^/failed_auth.html$
RewriteRule ^.
$ - [L]

#End Dreamhost stats fix

#Begin Wordpress

RewriteEngine On
RewriteBase /index.php/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php/index.php [L]

#End Wordpress[/code]6) When I have the index page and the WP files in the same directory, the relevant block of the .htaccess file - which works just fine - reads:

# BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase /wp_folder/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /wp_folder/index.php [L] </IfModule>7) I know that this can be made to work. For instance, user kchrist mentions here that his site works fine with such a set up.

Edited to Add: If someone who has successfully set up Wordpress on two levels (e.g., domain.tld/index.php points to domain/tld/wp/index.php) would be so good as to share the bit of their .htaccess that does the trick, I could probably take it from there…

Thanks very much for any assistance you can offer.

_dro


#2

This is the mod_rewrite section of my Wordpress site in its entirety. I use my own stats and error pages and so don’t care about making the DH default ones work. If this looks familiar, it’s because it’s what WP generated for me; I didn’t modify it at all. It lives in the root directory of my site.

[code]# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

END WordPress

[/code]I’m not sure I understand why this type of setup is problematic for some people. Even the notes on the WP wiki suggest some potential problems but I haven’t seen any of them. What I did, in a few easy steps:

  1. Install WP into /blog
  2. Copy /blog/index.php to /index.php
  3. Change the require() line in /index.php from:

require('./wp-blog-header.php'); to:

require('./blog/wp-blog-header.php'); 4. Keep the ‘Wordpress Address (URI)’ option as is, but change the ‘Blog Address (URI)’ to be the root of my site (ie, I just removed /blog).

That’s it. It just works. I’ve done this a number of times, on various sites, both on DH and at home in my development environment. These steps worked fine for my SO’s site as well. I’ve verified that this works, permalinks and all, under both PHP-CGI and mod_php, and using WP 1.5 or 2.0.

If this is a new site, kill everything and try this process. Let us know what happens.


If you want useful replies, ask smart questions.


#3

Thank you. I so owe you one.

Unfortunately, I can’t say for sure why it’s now fixed. First thing I did was change the mod_rewrite section as in your example. I had actually tried that version of the Wordpress section of .htaccess before as it made more sense to me than the version WP was telling me to enter (see original post.) Now - as then - nothing changed; I was still getting “no input file specified”.

So, I sorta took your advice in that I didn’t “kill everything”, but I did redo my index.php and the blog location and permalinks in the WP admin Options panel. I also deleted the wp-cache in the wp-content folder. And then IT WORKED (There was jubilation, let me tell you.)

I’d tried all of that before, but maybe not all at once. BBEdit tells me there’s no difference between the new index.php file and the old one… Was it the cache all the time? Don’t know.

I’m confused, but very, very happy. Thanks!

_dro (PS, I’ve moved it to it’s permanent location http://theplacebo.net)