Welcome Guest ( Log In | Register )



 
Reply to this topicStart new topic
> Last Rule In .htaccess, How is it used?
pyost
post Aug 3 2007, 11:43 AM
Post #1


Nenad Bozidarevic
Group Icon

Group: [MODERATOR]
Posts: 1,013
Joined: 7-November 05
From: Belgrade, Serbia
Member No.: 9,500



I am not particularly good when it comes to regular expressions and forming a .htaccess file, so I knew I would run into a problem sooner or later.

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.

CODE
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.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Custom Error Pages With .htaccess(11)
  2. .htaccess, Problems(1)
  3. I Need Help With .htaccess To Create A Login Form(0)
  4. Password Reminder And Password Change .htaccess(4)
  5. CDMA vs GSM(38)
  6. Help With Cgi And .htaccess(0)
  7. Need .htaccess Filesmatch Help(5)
  8. .htaccess Files Usage(3)
  9. CSS Priority Problem(7)
  10. .htaccess(2)
  11. Url Redirection/rewrite Using Htaccess(5)
  12. MS Access Validation Rule(2)
  13. .htaccess Redirecting Woes(5)
  14. HTAccessible: Modify Your .htaccess Visually(1)
  15. Is Any Publicity, Good Publicity?(2)
  1. Htaccess/gd Problems.(0)
  2. .htaccess Help(10)
  3. .htaccess Help As Well(1)


 



- Lo-Fi Version Time is now: 16th October 2008 - 04:11 AM