htaccess rewrite that will look for a filename the same as the directory name to server as an index
I like to avoid using index.php file names because it gets confusing in my code editor when I have numerous different index.phps open and I don't know which is which until I focus them.
Instead, I like the "index" file to be the same name of the directory I'm in.
Example:
Rather than this:
myapp/admin/index.php
myapp/user/index.php
I'd have this:
myapp/admin/admin.php
myapp/user/user.php
Yet I still wa开发者_如何学Gont my users to be able to go to just myapp/admin/ or myapp/user/ without having to tack on the filename.
Is there a way I can tell htaccess to look for a file matching the name of the directory and treat it as the index?
Write a RegEx RewriteRule. Somewhat like this:
RewriteRule myapp/(\w+)/(?:index\.php)? myapp/$1/$1.php
精彩评论