.htaccess URLRewrite rule - regular expression

I'm in need of a rewrite rule for a site of mine.

I have the following type of URLS:


But I would like that to read:


This is what I think should work:

RewriteRule ^-(.*) ?brand=$1

(it doesn't)

But then in addition, the ?brand parameter could actually appear as an &parameter - e.g. ?word=clutch&brand=TedBaker.

To summarise - I would like the brand parameter to be made into the final part of the static URL, preceded by the word 'by'. I would like this to work regardless of where the brand parameter appears in the URL string.

Here is the current .htaccess file:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

And here are all the URLs this needs to apply to:


Above need to be converted to /store/category/black-bags-by-jaeger/ or /store/category/black-bags-by-jaeger/?word=Cross%20Body (for 2nd and 3rd options).

I also have this: http://bag-saver.com/store/search/?brand=Jaeger which needs to be converted to /store/search/bags-by-jaeger/.


Try this : (if you can gives us all the variants of the url it would be better)

RewriteRule ^(.*)-by-([^/]+)/(.*)$ /$1/$3?brand=$2 [L,QSA]

Need Your Help

Invalid or unitialized Zip object

php zip

if(isset($_POST['items'])) {

Flume HDFS sink keeps rolling small files

hadoop hdfs twitter4j cloudera flume

I'm trying to stream twitter data into hdfs using flume and this: https://github.com/cloudera/cdh-twitter-example/

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.