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: