I would like:

  • sub.domain.com to load index.php
  • sub.domain.com?s=custom to load /custom/index.php

I am carrying this out at this time:


RewriteRule ^(custom)/?$ index.php?subject=$1

as well as in index.php I've this:

if($_GET['s'] == 'custom') {
   header( 'Location: http://sub.domain.com/custom/index.php' ) ;

... but can you really perform the redirect via htaccess itself with respect to the GET variable?


Yes, you can check query string with RewriteCond

RewriteCond %{QUERY_STRING} s=custom
RewriteRule ^(.*?)$ custom/index.php [L]

With this particular, it redirects all demands with existing "custom" get parameter to index.php, which is extended :)

Idea: http://statichtml.com/2010/mod-rewrite-baseon-on-query-string.html

You most likely desire to use "RedirectMatch"

RedirectMatch ^sub.domain.com?s=custom$  /custom/index.php

Maybe it's important to have fun with the regex abit