At the moment, I am developing a simple PHP script for a game similar to NotPr0n. As I want it to be user-friendly, I have decided to use "rewritten" URLs instead of something.php. Since the whole structure (i.e. possible URLs) is rather simple, I decided to write a set of rules manually. However, there is some overlapping, and it is causing me a lot of problems. Here is the current .htaccess file.
RewriteEngine on RewriteBase / RewriteRule ^(/)?$ inc/home.php [L] RewriteRule ^style.css$ style.css [L] RewriteRule ^izloguj-se(/)?$ inc/logout.php [L] RewriteRule ^([0-9]+)(/)?$ inc/level.php?num=$1 [L] # RewriteRule ^(.+)$ inc/file.php?name=$1
The homepage URL is riddle.mg-forum.net, and the first four rules work perfectly well:
riddle.mg-forum.net -> riddle.mg-forum.net/inc/home.php
riddle.mg-forum.net/style.css -> riddle.mg-forum.net/style.css
riddle.mg-forum.net/izloguj-se/ -> riddle.mg-forum.net/inc/logout.php
riddle.mg-forum.net/154/ -> riddle.mg-forum.net/inc/level.php?num=154 (154 can be any number)
Unfortunately, the last rule, which isn't active, isn't working properly. The idea is this: if the URL doesn't match any of the previous four, then the user must be asking for a certain file - or that is how the script should work. To achieve this, I have tried using [L] (last rule) for all the other statements as to skip the rest once the right line is found. But if I uncomment the last line, all the URLs will be rewritten to file.php?name=something! Am I using [L] improperly or is there another issue?
P.S. I wasn't quite sure whether this is the right forum, as I don't know how .htaccess and mod_rewrite are categorized. So, if any mod finds it appropriate to move the topic, feel free.