1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

.htaccess redirect /sub-directory/directory to /directory

Discussion in 'Apache' started by eklypse, Dec 11, 2010.

  1. #1
    I've been trying to use .htaccess to redirect files from /sub-directory/directory to /directory and I can't seem to find the right variation. This is the code I'm trying
    RewriteCond %{REQUEST_URI} !^/sub-directory/directory/.*$
    RewriteRule ^(.*)$ /directory/$1 [R=301,L]
    PHP:
    Thank you for any help.
     
    eklypse, Dec 11, 2010 IP
  2. eklypse

    eklypse Active Member

    Messages:
    84
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    93
    #2
    I'm actually trying to move domain.com/sub-directory/directory/file.html to domain.com/sub-directory/file.html (remove /directory from url)
    thanks in advance
     
    eklypse, Dec 13, 2010 IP
  3. eklypse

    eklypse Active Member

    Messages:
    84
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    93
    #3
    I found a working solution to my boggle, this works for what i needed.
    RewriteRule ^sub-directory/directory/?(.*) http://www.domain.wee/directory/$1 [R=301,L]
     
    eklypse, Dec 15, 2010 IP