+ Reply to Thread
Results 1 to 6 of 6

Thread: Simple htaccess RegEx

  1. #1
    nterror is offline x10 Sophmore nterror is an unknown quantity at this point
    Join Date
    Mar 2008
    Posts
    112

    Simple htaccess RegEx

    This has got to be simple, but for some reason I'm running into problems. :nuts:

    Trying to redirect links like the following:
    Code:
    http://mydomain.net/dirone/dirtwo/dirthree/etc/file
    That match
    Code:
    /dirtwo/dirthree/
    To
    Code:
    http://mydomain.net/page.htm
    Last edited by nterror; 05-29-2009 at 04:52 PM.

  2. #2
    garrettroyce's Avatar
    garrettroyce is offline Generally Helpful Member garrettroyce is a glorious beacon of lightgarrettroyce is a glorious beacon of light
    Join Date
    Apr 2008
    Location
    IL, USA
    Posts
    3,746

    Re: Simple htaccess RegEx

    I think this is right:
    Code:
    RewriteRule ^/dirtwo/dirthree/.*$ page.htm [R,NC,L]
    Rewrite URLs matching '/dirtwo/dirthree/' with any number of characters following, to page.htm, redirect, case insensitive, don't process any more rules.
    gjr.gr - coming soon: secrets of OCD coding from a self taught tinkerer

  3. #3
    nterror is offline x10 Sophmore nterror is an unknown quantity at this point
    Join Date
    Mar 2008
    Posts
    112

    Re: Simple htaccess RegEx

    I must be tired or something, I was missing a period. :laugh:

    Works, thanks.

  4. #4
    garrettroyce's Avatar
    garrettroyce is offline Generally Helpful Member garrettroyce is a glorious beacon of lightgarrettroyce is a glorious beacon of light
    Join Date
    Apr 2008
    Location
    IL, USA
    Posts
    3,746

    Re: Simple htaccess RegEx

    Glad it works. I was worried...I'm a little rusty on my htaccess regex ;)
    gjr.gr - coming soon: secrets of OCD coding from a self taught tinkerer

  5. #5
    vol7ron's Avatar
    vol7ron is offline x10 Lieutenant vol7ron is an unknown quantity at this point
    Join Date
    Mar 2008
    Location
    DC
    Posts
    434

    Re: Simple htaccess RegEx

    Not sure you need the ^, if you do you might need something like
    ^.*/dirtwo/dirthree/.*$ page.htm
    If you find my post useful please add to my reputation by clicking the +Rep button
    You may also use the Donate link to donate credits - this is appreciated too Thanks to those whom have donated so far!


  6. #6
    garrettroyce's Avatar
    garrettroyce is offline Generally Helpful Member garrettroyce is a glorious beacon of lightgarrettroyce is a glorious beacon of light
    Join Date
    Apr 2008
    Location
    IL, USA
    Posts
    3,746

    Re: Simple htaccess RegEx

    Yeah, you probably don't need the url start (^) in there. The only problem is if you don't and you have something like:

    /anotherdir/dirtwo/dirthree/... it will incorrectly match.
    gjr.gr - coming soon: secrets of OCD coding from a self taught tinkerer

+ Reply to Thread

Similar Threads

  1. Replies: 8
    Last Post: 01-29-2009, 03:01 PM
  2. Simple problem: Where to upload??
    By tiedup in forum Free Hosting
    Replies: 3
    Last Post: 12-20-2008, 12:09 PM
  3. HTACCESS Help
    By takuhii in forum Free Hosting
    Replies: 2
    Last Post: 09-30-2008, 03:35 PM
  4. Two very simple php file upload scripts-Free
    By Symbian.Ankit in forum Scripts & 3rd Party Apps
    Replies: 2
    Last Post: 02-20-2008, 09:55 AM
  5. How to protect images without htaccess using PHP
    By frznmnky in forum Tutorials
    Replies: 0
    Last Post: 12-26-2007, 11:51 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers