Jump to content



Welcome to AstaHost - Dear Guest , Please Register here to get Your own website. - Ask a Question / Express Opinion / Reply w/o Sign-Up!

Toggle shoutbox Shoutbox Open the Shoutbox in a popup

@  agyat : (23 May 2013 - 01:23 AM) Wow! Mr. Sb Back Home.
@  OpaQue : (23 May 2013 - 12:44 AM) Ting
@  OpaQue : (24 April 2013 - 02:44 PM) I guess, Time to run Mycent script.
@  OpaQue : (24 April 2013 - 02:43 PM) wow.. not much spam. except habatt posting lot of links.. :P
@  yordan : (23 April 2013 - 01:04 PM) You're welcome, agyat. Nice to have been helpful. Second lesson: try full words, "you" instead of "EW".
@  agyat : (23 April 2013 - 05:03 AM) @YORDAN: tHANK EW FOR YOUR FIRST LESSON.   :D
@  yordan : (22 April 2013 - 09:43 PM) @agyat : "why don't you help me", or "please help me", or "please teach us"
@  yordan : (22 April 2013 - 09:42 PM) welcome back, velma
@  velma : (22 April 2013 - 07:51 AM) **yawns** Good to be back, wonder what is going on here :)
@  agyat : (22 April 2013 - 03:50 AM) Oh! so, why don't help me learn english..
@  yordan : (21 April 2013 - 08:38 PM) The goal mentioned by shiu : "learning english, learning computer"
@  agyat : (21 April 2013 - 06:31 PM) WHAT GOAL?
@  yordan : (20 April 2013 - 10:39 AM) yes, that's our goal. simultaneouly learning English and teaching/learning computer using.
@  shiyu : (20 April 2013 - 07:30 AM) learning english,learning computer
@  yordan : (19 April 2013 - 01:11 PM) Oh, I see, it's just a trick in order to force people looking at your texte. Somehow smart, maybe.
@  agyat : (19 April 2013 - 02:54 AM) And of course I know it is not SEO friendly.
@  agyat : (19 April 2013 - 02:52 AM) There may be two possible answers for that ....


1) Shout was posted using mobile keypad.

2) To force people read content carefully and/or with more concentration.
@  agyat : (19 April 2013 - 02:49 AM) There may be two possible answers for that ....
@  yordan : (18 April 2013 - 09:35 PM) however, why this mixing of capital letters in the middle of your text?
@  agyat : (18 April 2013 - 11:10 AM) false feelings.

Replying to Last Rule In .htaccess


Post Options

    • Can't make it out? Click here to generate a new image

  or Cancel


Topic Summary

pyost

Posted 03 August 2007 - 11:43 AM

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.

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.

Review the complete topic (launches new window)