I have a subdirectory within my WP installation called labs
. I created a WP page called labs
as well. When a user hits mydomain.com/labs/
I want them to load up the WP page. But instead it’s loading up the labs
directory listing.
I’ve read a few ways to do this if I want my WP page to have a different name than my directory name, but I don’t really want that. For example, I want to have:
mydomain.com/ <-- WP Root
mydomain.com/labs/ <-- Pretty WP page listing all of my projects
mydomain.com/labs/project1/ <-- raw (i.e. no WP) web app
mydomain.com/labs/project2/ <-- raw (i.e. no WP) web app
Is this possible?
I should also mention that WP is installed in the root of mydomain.com
, so /labs/
is both a WP page and a subdirectory that I created manually.
Solution:
I renamed my labs
folder to projects
and used the following .htaccess.
RewriteEngine On
RewriteCond %{REQUEST_URI} labs/(.+)$
RewriteCond %{REQUEST_URI} !labs/(.+)/$
RewriteRule ^labs/(.+)$ http://mydomain.com/labs/$1/ [L]
RewriteRule ^labs/(.+)$ projects/$1 [L]
I’m a little unclear as to why I had to use
RewriteRule ^labs/(.+)$ http://mydomain.com/labs/$1/ [L]
instead of just
RewriteRule ^labs/(.+)$ labs/$1/ [L]
But when I used the latter it never appended the trailing slash.