I'm working with a semi-old site that has used underscores throughout the base web directory. (how_to_do_this.php, who_is_author_name.php, etc.) Part of the redesign we are going to have categories (how-to, who-is) just as an example. To keep everything organized in the base directory we were going to change the naming convention for the URL to "folder-in-url / file-name-in-url.php" with filenames as "folder-in-url_file-name-in-url.php". Notice the underscore is the seperater for the URL so the stuff before the underscore is essentially a folder according to the URL.
ORIGINAL FILENAME -> RENAMED FILENAME -> URL
folder_in_url_file_name_in_url.php -> folder-in-url_file-name-in-url.php -> /folder-in-url/file-name-in-url.php
how_to_do_this.php -> how-to_do-this.php -> /how-to/do-this.php
who_is_author_name.php -> who-is_author-name.php -> /who-is/author-name.php
Is this possible using .htaccess / mod-rewrite? In other words, when someone goes to example.com/how-to/do-this.php then apache will look and present the content of the file "how-to_do-this.php" rather than looking in the how-to folder for do-this.php? Please note that when someone goes to the example.com/how-to/do-this.php it does NOT redirect them to example.com/how-to_do-this.php.
Any help is greatly appreciated. At the end of the day, we can make the folders and put the files in their appropriate folders but then the base web directory will be chuck full of folders whereas for maintenance it would be easier just to administer within the base directory using appropriate filenames with an underscore separating for URL purposes.
Best practices is preferred, so if this is a "hack" and not recommended then we can do folders and put the files within the appropriate "category" folders. Thanks!