Forum Moderators: phranque
here are my rules for it.
RewriteEngine On
Options +FollowSymlinks -MultiViews
RewriteRule ^news/([^/]+)/?$ /news.php?urltitle=$1 [L]
RewriteRule ^news/page/([^/]+)/?$ /news.php?page=$1 [L]
RewriteRule ^content/([^/]+)/?$ /content.php?urltitle=$1 [L]
RewriteRule ^news/topic/([^/]+)/([^/]+)/?$ /news.php?tid=$1&topictitle=$2 [L]
RewriteRule ^news/topic/([^/]+)/([^/]+)/page/([^/]+)/?$ /news.php?tid=$1&topictitle=$2&page=$3 [L]
Any suggestions on getting the page one to work?
All I do know is that I keep reading in this forum that you're supposed to put your most specific rules first. So if that's more specific than others, try putting the specifics first and see if that helps. To me it looks like it might be more specific than others that come before it (but I could be wrong).
What I'm referring to is the order of directives. Here's just one thread on it, there are a lot of others in this forum that you can search for, too:
[webmasterworld.com...]
[edited by: Marcia at 6:08 am (utc) on Dec. 23, 2007]
I often wrote or adapted some code and it did exactly what it was coded to do, but that was often not quite what I actually wanted or needed it to do.
Defining which URLs it is to work for, and which it is not be used for, is half of the battle.
I want this one to work for http://www.example.com/news/topic/1/Topic_Title
RewriteRule ^news/topic/([^/]+)/([^/]+)/page/([^/]+)/?$ /news.php?tid=$1&topictitle=$2&page=$3 [L]
i want this one to work for http://www.example.com/news/topic/1/Topic_Title/page/#
the second one does not work.
[edited by: jdMorgan at 12:19 am (utc) on Dec. 24, 2007]
[edit reason] example.com [/edit]
ROFL, never realized what a fun forum this is. :)
/Topic_Title/page/# is more specific than
/Topic_Title
So if more specific is supposed to be coded before less specific (more general), shouldn't it come before /Topic_Title in the coding order? Or am I missing something?
Here's a post about how the sequencing works, very simply and clearly explained. Even though it's for a different issue, the principle of sequencing is the same:
[webmasterworld.com...]
The Redirect directive uses prefix-matching. Therefore, your less-specific whole-directory Redirect directives will always be invoked because they come first in your posted code, and the more-specific per-file ones won't ever be invoked.
Always order your redirects and rewrites from most-specific (longest URL-path) to least-specific.
[edited by: Marcia at 12:33 am (utc) on Dec. 24, 2007]
If you have a piece of code that applies to A and a piece of code that applies to AB (longer!) and you put the "A" code first then it will run for both A and AB inputs. The code you wrote especially for AB never gets to run.
So you put the code for AB first, and it runs only when an input of AB triggers it, and then exits. An input of just "A" will not trigger it, so the server tries the next piece of code in case that one does, and in this case it does, so it then runs.
Most specific goes first.
Most specific goes first.
the log entry would be interesting.