.htaccess Help please.

Discussion in 'Apache' started by Millar, Mar 24, 2007.

  1. #1
    How would I rewrite domain.tld/anything/_a_file_or_another_directory_here to domain.tld/a_set_dir/_the_file_or_dir

    e.g domain.com/blah/image/poo.gif -> domain.com/set_dir/image/poo.gif
    or domain.com/mcsdfg/index.php?foo=bar -> domain.com/set_dir/index.php?foo=bar

    Thanks in advanced,
    Millar.
     
    Millar, Mar 24, 2007 IP
  2. rodney88

    rodney88 Guest

    Messages:
    480
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    0
    #2
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !^set_dir
    RewriteRule ^([^/]+)/(.+) set_dir/$2 [L]
    Code (markup):
    Checks the request isn't already in set_dir and then does the rewrite.
     
    rodney88, Mar 24, 2007 IP
    Millar likes this.
  3. Millar

    Millar Peon

    Messages:
    334
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks! It works!!
     
    Millar, Mar 25, 2007 IP