SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2005
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question .htaccess domain name folder

    Hey guys,

    This line is causing a lot of issues:

    RewriteRule ^([_A-Za-z0-9\.-]+)(/)?$ index.php?strURL=$1

    I basically want it so that when someone goes to domain.com/domain.com , it points to domain.com/index.php?strURL=domain.com and opens the page passing "domain.com" as a param of index.php

    Any clues?

    Thanks in advance,
    Armin
    Online Games - Play Free Online Games
    Arcade Games - Tons of Arcade Games
    Watermark Tool - Protect your Photos

  2. #2
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,645
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    Armin,
    Code:
    RewriteRule ^([_A-Za-z0-9\.-]+)(/)?$ index.php?strURL=$1
    That mod_rewrite says to start with one or more letter, digit, dot character (which is NOT supposed to be escaped in a character range definition), underscore or hyphen, followed with a trailing slash (or not) before the end of the string and redirect to index.php with the query string strURL={the first atom} (WHY make an atom of the trailing /?). Of course, this SHOULD loop as the regex also matches index.php as well as any other filename you may have in that directory.
    Quote Originally Posted by Armin
    Any clues?
    I've NO clue what you're trying to do. However, it's evident that you need a little bit of a tutorial in mod_rewrite so I invite you to have a read through the appropriate parts (i.e., AT LEAST Regex and the Examples) of the tutorial linked in my signature. You know where to find me to ask when you have questions.

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  3. #3
    SitePoint Enthusiast
    Join Date
    Oct 2005
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question

    Quote Originally Posted by dklynn View Post
    Armin,
    Code:
    RewriteRule ^([_A-Za-z0-9\.-]+)(/)?$ index.php?strURL=$1
    That mod_rewrite says to start with one or more letter, digit, dot character (which is NOT supposed to be escaped in a character range definition), underscore or hyphen, followed with a trailing slash (or not) before the end of the string and redirect to index.php with the query string strURL={the first atom} (WHY make an atom of the trailing /?). Of course, this SHOULD loop as the regex also matches index.php as well as any other filename you may have in that directory.

    I've NO clue what you're trying to do. However, it's evident that you need a little bit of a tutorial in mod_rewrite so I invite you to have a read through the appropriate parts (i.e., AT LEAST Regex and the Examples) of the tutorial linked in my signature. You know where to find me to ask when you have questions.

    Regards,

    DK

    I'm trying to write a mod rewrite to point example.com/domain.com => example.com/index.php?strURL=domain.com

    So people can type example.com/yahoo.com and it would load index.php passing yahoo.com into the get parameter.

    WHY make an atom of the trailing /?
    I'm not. I'm an atom for the FIRST group being ([_A-Za-z0-9\.-]+). I guess the "?" does not need brackets around it, but it doesnt make a difference in this case.

    Rules I've written like this one:
    RewriteRule ^([_A-Za-z0-9-]+)(/)?$ game.php?strPage=$1

    work just fine, but as soon as I want "." to be included, it messes up.

    Now, thanks for your reply, but I did not need to hear a lesson, I needed help on finding a solution. I'm a Software Engineer with over 10 programming languages and 4 human languages in my head. I'd appreciate some assistance here.

    Armin
    Online Games - Play Free Online Games
    Arcade Games - Tons of Arcade Games
    Watermark Tool - Protect your Photos

  4. #4
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,645
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by arminebusch View Post
    I'm trying to write a mod rewrite to point example.com/domain.com => example.com/index.php?strURL=domain.com

    So people can type example.com/yahoo.com and it would load index.php passing yahoo.com into the get parameter.

    I'm not. I'm an atom for the FIRST group being ([_A-Za-z0-9\.-]+). I guess the "?" does not need brackets around it, but it doesnt make a difference in this case.
    But you did create a second atom with the "(/)?". MINOR point but, IMHO, you could learn from it.
    Rules I've written like this one:
    RewriteRule ^([_A-Za-z0-9-]+)(/)?$ game.php?strPage=$1

    work just fine, but as soon as I want "." to be included, it messes up.
    Think: Why would it mess up? You SHOULD quickly come to the obvious answer that it matches ALL your files in that directory. The objective you need to turn to is how to EXCLUDE those files.
    Now, thanks for your reply, but I did not need to hear a lesson, I needed help on finding a solution. I'm a Software Engineer with over 10 programming languages and 4 human languages in my head. I'd appreciate some assistance here.
    Do you consider "assistance" to be "free coding" or "helping you learn?" If you weren't here for a lesson, WHY did you come and ask for assistance?

    [aside]If you are asking for "free coding," please let me know. You should know that I don't do coding for "script kiddies" - which I didn't believe you were or I wouldn't bother responding.[/aside]

    Did you bother to read the tutorial? IMHO, you NEED to read the regex section then use your training as a programmer to think about the problem logically: Redirect letters, digits and dots to your index.php script ... WITHOUT redirecting other files. Hmmm, there is a RewriteCond code which addresses whether the {REQUEST_URI} is a file or not. If you have read my signature's tutorial, you'd know the format of that mod_rewrite statement and how to prepend it to your RewriteRule.

    BTW, I mean no offense by being pedantic. My purpose of spending my time here in this forum is to help others LEARN.

    Yes, another lesson but I hope that you can learn from it and, ultimately, help others learn, too.
    Armin
    Regards,

    DK
    Last edited by dklynn; Apr 7, 2010 at 17:30. Reason: colorizing
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •