删除文件扩展名并允许“伪目录”?

I'm creating a fairly simple website. There are two static pages (Home and Portfolio) in the root folder, and Wordpress in /blog. The static pages includes Wordpress using require_once("blog/wp-config.php");.

The portfolio page will be using Javascript (either History.JS or Crossroads/Hasher) to "push" URLs representing the categories and albums. For example, clicking "Weddings" on the left will result in portfolio/weddings, and an album would be portfolio/weddings/jane-jon-smith. These files need to be available when accessed directly (I send you a link to the album).

Right now, I have it set up so that the static pages are accessible from index.php and portfolio.php. I was able to remove the file extensions using the following .htaccess directives:

# Remove .php-extension from url
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^([^\.]+)/$ $1.php [L]

But when I try to visit a URL such as portfolio/weddings, I get a 404 error because that isn't a valid directory or file. I've been searching, but can't seem to find anything related, other than how to remove the extension (which I have working).

How do I remove the file extension and also allow direct access to these "fake" directories?

After posting my comment to the question, it hit me that maybe I should redirect anything matching "portfolio/*" to portfolio.php, and from there I can deal with the path using a few functions (which is successfully working now).

All I did was add this line immediately after the rules I listed in the question:

RewriteRule ^portfolio/([^/]+) /portfolio.php?$1 [NC]

Wordpress usess a front controller to create what you're calling "psuedo-directories". It gets the parameters of the url, and routes it to the application controllers accordingly to build the view layer, or what the client sees.

In order for Wordpress to route this request accordingly, you need to have a corresponding page for each portfolio entry. You can use the default functionality of Wordpress to do this. Undo the changes to your .htaccess file, and instead change the Permalink settings inside the Settings to "Post Name".

It would probably be easier just to use the dynamic portfolio that's built in than a custom rolled "widget" for your static page. Your static pages can be set to display portfolio items with the right WP theme.

The great thing about Wordpress is the very advanced things it can do, just by altering settings in the dashboard. I suggest you spend some time studying what each feature can do, and you'll save a lot of time, and a lot of headaches down the road, by not having to troubleshoot your own code when WP rolls out the next version in December.