Help with mod rewrite, willing to pay for if needed

Discussion in 'Apache' started by edual200, May 16, 2008.

  1. #1
    These below work fine and i do have dynamic subdomains working....

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^([^.]+)\.mydomain\.com?$
    RewriteRule ^$ search.php?q=%1 [QSA,L]


    RewriteEngine On
    RewriteRule ^(.*)/(.*)/(.*)/$ search.php?q=$1&t=$2&s=$3 [QSA,L]


    But what i would like to get to work is something like
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^([^.]+)\.mydomain\.com/([^.]+)/([^.]+)/?$
    RewriteRule ^$ search.php?q=%1&t=%2&s-%3 [QSA,L]


    Basically the subdomain would be 1 of the search parameters and then the 2 sobfolders are the other 2 search parameters. is it possible?
     
    edual200, May 16, 2008 IP
  2. Cybernaut

    Cybernaut Peon

    Messages:
    408
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Combine your two blocks of rewrite code like this:

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^([^.]+)\.mydomain\.com?$
    RewriteRule ^/([^/]+)/([^/]+)/?$ search.php?q=[b][color=red]%1[/color][/b]&t=[b][color=green]$1[/color][/b]&s=[b][color=green]$2[/color][/b] [QSA,L]
    Code (markup):
    %1 from RewriteCond, and $1 and $2 from RewriteRule pattern matches. But whats that '?' doing there after domain name (mydomain\.com?$)? You should remove that.
     
    Cybernaut, May 16, 2008 IP