More information about the Underscore mailing list

[_] Mod-rewrite pattern match

Russ Back russ at fuel-digital.com
Tue May 21 12:55:43 BST 2013

Awesome, thanks Oliver

> RewriteEngine On
> RewriteCond %{QUERY_STRING} &tile=([0-9a-zA-Z-]+)
> RewriteRule tiles tiles/details/%1 [R]
> 
> (Whether you use "tiles" or "^tiles" or "^/tiles", etc, as the test in the RewriteRule depends on whether this is going in .htaccess or httpd.conf, and your URL layout.)

This is .htaccess file. Tried the above but with a test URL I get a redirect loop. Removing the dupe "tiles" in the rewrite rule cures that but the URL has been resolved rather than redirected - my bad for not being clearing enough! I am looking to 301 redirect them - can you tell me what I need to add to do that?

On 21 May 2013, at 12:45, Oliver Humpage <oliver at watershed.co.uk> wrote:

> 
> On 21 May 2013, at 12:40, Russ Back wrote:
> 
>> Been scratching my head over this one. I have a URL format I need to redirect and only need one part of the querystring. Example URL:
>> 
>>> tiles?shape=&colour=&finish=&material=&price=&o=60&tile=50-double-roman-antique-red-03-granular
>> 
>> All I need from this is the value of the tile parameter so I can then redirect it to:
>> 
>>> tiles/detail/50-double-roman-antique-red-03-granular
>> 
>> Any suggestions for a mod-rewrite rule?
> 
> RewriteRule won't match query strings, so you need a slightly different approach:
> 
> RewriteEngine On
> RewriteCond %{QUERY_STRING} &tile=([0-9a-zA-Z-]+)
> RewriteRule tiles tiles/details/%1 [R]
> 
> (Whether you use "tiles" or "^tiles" or "^/tiles", etc, as the test in the RewriteRule depends on whether this is going in .htaccess or httpd.conf, and your URL layout.)
> 
> HTH
> 
> Oliver.
> -- 
> underscore_ list info/archive -> http://www.under-score.org.uk/mailman/listinfo/underscore