Forum Moderators: phranque
Below is what I have
rewriterule ^article/([^&]+)/([^&]+)$ index.php?article_id=$1&article_name=$2 [L]
Which works fine with this in the url "article/1234/test_article"
But what I need is to see if there is another variable passed after the article name. And if there is I need to grab another.
Any help would be great! thanks!
Also, if you're not sure what "[^&]+" means, I suggest you look into it, because that pattern seems inappropriate for use in your described application. Indeed, if you've tried writing a second rule and have had problems with the two rules working together in a particular order, this is the likely cause.
There's a concise regular-expressions tutorial cited in our Forum Charter (ee link at top of this page).
Jim
rewriterule ^article/([^&]+)/([^&]+)/([^&]+)/article_title/([^&]+)$ index.php?article=$1&module=$2&id=$3&article_title=$4 [L]
rewriterule ^article/([^&]+)/([^&]+)/article_title/([^&]+)$ index.php?article=$1&module=$2&article_title=$3 [L]
rewriterule ^article/([^&]+)/([^&]+)/([^&]+)$ index.php?article=$1&module=$2&cmd=$3 [L]
rewriterule ^article/([^&]+)/([^&]+)$ index.php?article=$1&module=$2 [L]
I would suggest changing those patterns, for example, making your first rule look like this:
RewriteRule ^article/([^/]+)/([^/]+)/([^/]+)/article_title/(.+)$ index.php?article=$1&module=$2&id=$3&article_title=$4 [L]
Apply that same approach to your other rules as well; Note that the last sub-pattern of the four in the example above is intentionally different.
Using 'the right regular expressions for the job' at hand is important; Don't ignore this aspect of using mod_rewrite.
Jim