banana_man — 2013-04-30T04:47:36-04:00 — #1
I'm trying to get my article url's to just have the domain name, article title and article id e.g. www.mydomin.com/article-title-1.
I can do this with the following:
RewriteRule ([A-Za-z0-9-]+)-([0-9]+) dynamic/index.php?dynamic_url=$1&id=$2
but this seems to interfere with any file in the entire site that ends in the format of a string/number-number e.g. www.mydomain.com/images/image-1
Is their a way of specifying this rewrite condition on to files appearing directly after the domain name?
jeff_mott — 2013-04-30T07:49:54-04:00 — #2
You can use ^ to ensure your pattern starts matching at the beginning of the string, and $ to ensure it finishes matching at the end of the string. Otherwise, your pattern could be matching any middle portion of your strings.
RewriteRule ^([A-Za-z0-9-]+)-([0-9]+)$ dynamic/index.php?dynamic_url=$1&id=$2
banana_man — 2013-04-30T09:54:52-04:00 — #3
Brilliant! That's got it sorted.