I have a website for my car enthusiast club ("example.org") whose content can be divided into three main sections: Startseite (the "front page" of the site), Mitglieder (membership directory), and Vereinsinfos ("about us"). For each section, the content is handled by a corresponding PHP script: /home.php
, /mitglieder.php
, and /verein.php
.
I'd like to prettify the URLs to eliminate the .php
extensions, so that the URLs look like
http://example.org/home
(maps to/home.php
)http://example.org/home/
(also maps to/home.php
)http://example.org/home/1
(maps to/home.php
with adata=1
query string)
After reading all documentation, I formed my .htaccess
like this (repeated for the mitglieder
and verein
sections):
RewriteRule ^home\/$ /home.php [L]
RewriteRule ^home$ /home/ [L]
RewriteRule ^home\/([^/]*)$ /home.php?data=$1 [L]
This works, but I can't figure out how to improve it further after reading all the documentation on the Internet. (I have difficulty understanding regular expressions.)
In addition to the content above, I also have static resources under /images/
, /js/
, /css/
, etc. which should be left alone.
/home
, then it gets mapped to/home/
— is the content then generated by/home/index.html
or some otherDirectoryIndex
-configured handler? Is that what you want? \$\endgroup\$/images/
have to do with your rules? \$\endgroup\$index.php
?link.php
? The plot thickens… those weren't mentioned anywhere in the question. Could you include a recursive directory listing? \$\endgroup\$