Forum Moderators: phranque
I've been reading many posts on this but can't quite work out the regular expression. I am migrating my site to Joomla 1.5 and their SEF urls are not the same as my current site (Joomla 1.0) but the parameters will work
ie:
domain.com/content/view/2161/30/
will work as:
domain.com/jokes/30/2161
Is there a rewrite rule I can use for this?
It would be helpful to make this clear by doing something like this:
example.com/content/view/<item-number:digits-only>/<category:digits-only>/ --rewrite to--> /jokes/<categoty>/<item-number>
domain.com/content/view/<item-number:digits-only>/<category:digits-only>/ --rewrite to--> /script.php/cat=<category>&item=<item-number>
to show what is fixed, what is a variable, how the variables are ordered in both the input and output, what kind of characters are acceptable in each variable, and what the destination path should be.
Also, you should say if you want to simply deliver content from the new path when the old URL is requested, or instead to redirect requests for the old path to the new path, so that search engines will update their databases to use the new URL(s).
Jim
RewriteRule ^content/view/([0-9]+)/([0-9]+)/?$ /jokes/$2/$1/ [L,R=302]
I am stuck on another one. My Rule (that does not work)
RewriteRule ^component/option,com_rsgallery2/Itemid,45/page,inline/id,([0-9])/catid,([0-9])/limitstart,0/?$ /index.php?page=inline&id=$1 [L,R=302] Using this rule its not redirecting. The Old URL that I'm trying to match is
component/option,com_rsgallery2/Itemid,45/page,inline/id,971/catid,15/limitstart,0/
I hope thats more defined.
Regular-expressions quantifers are:
? -- Zero or one of the preceding characters
* -- Zero or more of the preceding characters
+ -- One or more of the preceding characters
{n} -- n characters. Example: {3} "Three of the preceding characters"
{min,max} - any quantity between and including min and max. Example: {2,5} "from 2 to five of the preceding characters"
{min,} -- Any quantity including or above min. Example: {2,} "two or more of the preceding characters"
{,max} -- Any quantity including or below max. Example: {,9} "zero to nine of the preceding characters"
So in your case, you might use ([0-9]{2}) for the first numeric subpattern and ([0-9]{3}) for the second, if you're always looking to match 2-digit catIDs and 3-digit ItemIDs. Or you could specify an acceptable range, such as ([0-9]{1,4}) for both of them, or just accept any number of digits, by using ([0-9]+).
Jim