Help with rewrite

Using mod_rewrite to handle various content issues

Help with rewrite

Postby Guest » Wed Dec 29, 2004 6:22 pm

What's wrong with this:

Code: Select all
RewriteEngine On

RewriteRule ^(.*)/([0-9]{10}) main.php?ucat=$1&subaction=showfull&id=$2 [QSA]

RewriteRule ^link-([a-z]+)\.html$ main.php?bla,$1,go

RewriteRule ^(.[^/]+)/(.[^/]+)\.html$ main.php?bla,$1,$2 [L]


The second line after "RewriteEngine On" is for CuteNews, so that the news become more 'friendly' like http://bla.net/1/234241234 and it works.

The third line is for redirecting links...and it works.

The last line is for general content and it seems to work.

But whenever I request a regular file in a sub-directory like http://bla.net/test/bleh.html I am redirected to the main page! Even though the file exists. What's wrong? Am I doing anything wrong?

Any advice or help is welcome.
Guest
 

Postby Caterham » Thu Dec 30, 2004 7:56 am

Am I getting you right, that you don't want to match the last rule, if a reular exsisting file is requested?
Caterham
 
Posts: 690
Joined: Fri Dec 10, 2004 1:30 pm

Postby Guest » Sat Jan 01, 2005 4:53 am

Correct
Guest
 

Postby Caterham » Sat Jan 01, 2005 9:26 am

Then you can try
Code: Select all
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -l
RewriteRule ^.* - [L]

RewriteRule ^(.*)/([0-9]{10}) main.php?ucat=$1&subaction=showfull&id=$2 [QSA,L]

RewriteRule ^link-([a-z]+)\.html$ main.php?bla,$1,go [L]
RewriteRule ^(.[^/]+)/(.[^/]+)\.html$ main.php?bla,$1,$2 [L]
The rewrite process should be skipped if REQUEST_FILENAME is either a file or symbolic link.

Bob
Last edited by Caterham on Sun Jan 02, 2005 7:53 am, edited 1 time in total.
Caterham
 
Posts: 690
Joined: Fri Dec 10, 2004 1:30 pm

Postby Guest » Sat Jan 01, 2005 3:40 pm

Everything works correctly except if a file is requested which is located in a sub-directory - if such a file IS requested i am taken to the main page...

for instance:

http://bleh.net/FILENAME.html << would work

but NOT:

http://bleh.net/FOLDER/FILENAME.html

Even though FILENAME.html IS located in FOLDER....What am I doing wrong?
Guest
 

Postby Caterham » Sun Jan 02, 2005 7:52 am

Sorry, I forgot the OR-Flag. I corrected the rule above
Caterham
 
Posts: 690
Joined: Fri Dec 10, 2004 1:30 pm

Postby Guest » Sun Jan 02, 2005 11:28 am

Ah yes, now it works well Caterham!

Thank you once again - very helpful of you.

Greetings.
Guest
 


Return to Content

Who is online

Users browsing this forum: No registered users and 14 guests

cron