+ Reply to Thread
Results 1 to 2 of 2

Thread: Htaccess - regular expressions

  1. #1
    lair360 is offline x10 Sophmore lair360 is an unknown quantity at this point
    Join Date
    Dec 2008
    Posts
    200

    Htaccess - regular expressions

    Version: 16.1a
    Revision: 33 Build 18


    Htaccess - regular expressions

    Introduction: many users these days aren’t sure about “htaccess” syntax and their regular expressions. So, I’ve written this article to stop you from getting confuse!


    . (full stop) - match any character and any single character
    * (asterix) - match zero or more of the previous symbol
    ———————————
    Notes: * - means one or more of the preceding characters


    + (plus) - match one or more of the previous symbol
    ? (question) - match zero or one of the previous symbol
    \? (backslash-something) - match any special characters
    ^ (caret symbol) - match the start of a string

    # - this symbol is a commented-out line
    ——————————–
    Notes: ^ - refers to the beginning of a string. So any syntax that has ^ in it means “starts with”


    $ (dollar symbol) - match the end of a string
    ——————————–
    Notes: $ - refers to the end of the string. So any syntax that ends with $ means “ends with” the previous character


    [set] - match any of the symbols inside the square braces
    (pattern) - grouping, remember what the pattern matched as a special variable


    Extended information
    ——————————–
    ^$ - refers to a string that starts and stops with nothing in between, also known as an empty string, as there’s nothing in it.


    ^demo.* - refers to a string that starts with “demo” and then may contain any number of any characters.


    ^globalnews\.net$ - refers to a string that contains only “globalnews.net”


    ! symbol is a negation. Anywhere you see a ! (exclaimation mark), it means denied or exclude. So, “!string”, matches everything except (exclude) string.


    Exclusion is a very useful method and it will allow your domain from being block by htaccess as bad referrers and agent-robots.


    !^friend1@client1.mydomain\.com$


    Notes: the ! symbol notify the engine to exclude “friend1@client1.mydomain” from a “.com” domain. This way, your website or friend’s site will not get block.


    ——————————–
    Advice: ^(.*)$ - the ^ (caret) symbol defines the start, (.*) is a designated variable (using brackets) containing a regular expression that matches any combination of characters, and the $ symbol defines the end.


    That is all everyone and thank you for your support!


    Copyrighted by Lair360

  2. #2
    gautam's Avatar
    gautam is offline x10Hosting Member gautam is an unknown quantity at this point
    Join Date
    Apr 2008
    Posts
    7

    Re: Htaccess - regular expressions

    Awesome...helped a lot! thanx

+ Reply to Thread

Similar Threads

  1. Replies: 8
    Last Post: 01-29-2009, 03:01 PM
  2. HTACCESS Help
    By takuhii in forum Free Hosting
    Replies: 2
    Last Post: 09-30-2008, 03:35 PM
  3. Internal Server Error
    By Tom743 in forum Free Hosting
    Replies: 10
    Last Post: 08-28-2008, 01:16 PM
  4. .htaccess redirect with regular expressions
    By Scoochi2 in forum Programming Help
    Replies: 0
    Last Post: 08-25-2008, 07:07 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