1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

HTACCESS Not Working

Discussion in 'General Scripting Chat' started by The Scarlet Pimp, Aug 20, 2010.

  1. The Scarlet Pimp

    The Scarlet Pimp Jr. VIP Jr. VIP Premium Member

    Joined:
    Apr 2, 2008
    Messages:
    788
    Likes Received:
    3,129
    Occupation:
    Chair moistener.
    Location:
    Cyberspace
    this doesn't work for some reason... :confused:
    i want to redirect all traffic from the subfolder,
    even if someone misspells the name of the folder.

    i have the redirection part correct, but the condition
    part (seen below) isn't working correctly...

    Code:
    RewriteCond %{REQUEST_URI} !^/subfolder/$ [NC]
     
  2. rocket

    rocket Regular Member

    Joined:
    Apr 14, 2009
    Messages:
    471
    Likes Received:
    131
    Occupation:
    Web developer and marketer
    Location:
    In my competitor's mind
    I don't have the exact answer, but you can probably find what you need here. Sometimes better to solve a problem yourself:

    Code:
    http://perishablepress.com/press/2006/01/10/stupid-htaccess-tricks/
     
  3. The Scarlet Pimp

    The Scarlet Pimp Jr. VIP Jr. VIP Premium Member

    Joined:
    Apr 2, 2008
    Messages:
    788
    Likes Received:
    3,129
    Occupation:
    Chair moistener.
    Location:
    Cyberspace
    i already looked there... and over a half-dozen other sites.
    (it's only better if it doesn't take up hours)
     
  4. cyklotrial

    cyklotrial Regular Member

    Joined:
    Oct 13, 2008
    Messages:
    248
    Likes Received:
    82
    Location:
    Wonderland
    Try redirect all "subfolder" (misspelled or no) traffic to single php file and use
    similar_text and levenshtein function to find out if it was misspeled wor or no.
    Than redirect or no.

    With only htaccess it will be very hard to catch all misspelled word versions.
     
  5. The Scarlet Pimp

    The Scarlet Pimp Jr. VIP Jr. VIP Premium Member

    Joined:
    Apr 2, 2008
    Messages:
    788
    Likes Received:
    3,129
    Occupation:
    Chair moistener.
    Location:
    Cyberspace
    when i said 'misspelled', i meant case-wise. that's why i put the
    [NC] tags at the end. but it's not working.

    this is the whole code, it works but not if the domain name is capitalized.
    can this be fixed???

    Code:
    
    RewriteCond %{REQUEST_URI} !^subfolder/.$ [NC]
    RewriteRule ^(.*)$ http://newdomain.com? [NC,R=301,L]
    
    
     
  6. cyklotrial

    cyklotrial Regular Member

    Joined:
    Oct 13, 2008
    Messages:
    248
    Likes Received:
    82
    Location:
    Wonderland
    1) Do not use NC in RewriteRule
    2) Add this line:
    RewriteCond %{HTTP_HOST} domain.com [NC]
     
  7. The Scarlet Pimp

    The Scarlet Pimp Jr. VIP Jr. VIP Premium Member

    Joined:
    Apr 2, 2008
    Messages:
    788
    Likes Received:
    3,129
    Occupation:
    Chair moistener.
    Location:
    Cyberspace
    this is what i've got... still no go :confused:

    RewriteCond %{HTTP_HOST} ^mydomain\.com/subfolder/ [NC]
    RewriteRule ^(.*)$ http://gohere.com? [R=301,L]
     
  8. cyklotrial

    cyklotrial Regular Member

    Joined:
    Oct 13, 2008
    Messages:
    248
    Likes Received:
    82
    Location:
    Wonderland
    try this one:
    Code:
    RewriteRule ^subfolder http://www.gohere.com [NC,L,R=301]
     
  9. Entrepreneur

    Entrepreneur Regular Member

    Joined:
    Oct 12, 2007
    Messages:
    438
    Likes Received:
    379
    I'm not sure how you can redirect all misspellings without some hardcore regex work in the htaccess.

    Why not put another htaccess in the subfolder and one in each subfolder you think that it might be misspelled as and simply redirect all requests that way?

    Also, did you actually need to catch the full page url, because you could simply stick a php page in each folder, along with the htaccess? You could then have htaccess direct all queries within that dir to the php page, which then 301s to whatever page you need.
     
  10. The Scarlet Pimp

    The Scarlet Pimp Jr. VIP Jr. VIP Premium Member

    Joined:
    Apr 2, 2008
    Messages:
    788
    Likes Received:
    3,129
    Occupation:
    Chair moistener.
    Location:
    Cyberspace
    i tried this, also doesn't work:

    Redirect 301 /subfolder http://gohere.com/ [NC]

    all i really need is to make the request string case-insensitive.
    sometimes people spell the subfolder name like, SubFolder
    which sends them to my 404 page, instead of where i want to send
    them.

    if i could make the 'rewrite condition' case-insensitive then the
    'rewrite rule' would take care of the redirection.
     
  11. cyklotrial

    cyklotrial Regular Member

    Joined:
    Oct 13, 2008
    Messages:
    248
    Likes Received:
    82
    Location:
    Wonderland
    The Scarlet Pimp
    Use ONLY this line :) Without any rewritecondition...
    Code:
    RewriteRule ^subfolder http://www.gohere.com [NC,L,R=301]
    i have tested it on 2 servers and localhost and its working briliant
     
  12. The Scarlet Pimp

    The Scarlet Pimp Jr. VIP Jr. VIP Premium Member

    Joined:
    Apr 2, 2008
    Messages:
    788
    Likes Received:
    3,129
    Occupation:
    Chair moistener.
    Location:
    Cyberspace
    Thanx fer da help, boyos!