SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2006
    Posts
    73
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    .htaccess help needed-error 500.

    Hi,

    I am using this .htaccess code inside the glitter1 folder.

    Code:
    RewriteRule ^images/([^/]+)$ /glitter1/images/$1 [L]
    RewriteRule ^([^/]+)/([^/]+)/?$ /glitter1/flashdisplay.php?root=$1&cat=$2 [L]
    Here the second rule defines this type of url- http://www.mysite.com/glitter1/animals/lions/

    My problem is that this is stopping the images in this folder from showing. (It is showing internal server error)
    http://www.mysite.com/glitter1/images/goodday1.gif

    Is there any way to cause the 2nd redirectrule to be skipped if the url is of the format- http://www.mysite.com/glitter1/images/

    I tried using this code but I dont think its the correct syntax.
    Code:
    RewriteRule ^([^/][^images]+)/([^/]+)/?$ /glitter1/flashdisplay.php?root=$1&cat=$2 [L]
    I hope I am making myself clear.

    Thanks,

    Nishant

  2. #2
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,680
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    nish,

    Oh, my! Didn't we just go through this in another thread?

    Your regex tells me that you do not know how to write regex so, if you can't get the regex "bible" (Mastering Regular Expressions by Friedl) or Bowen's mod_rewrite book (The Definitive Guide to Apache mod_rewrite), then at least have a look at the tutorial Article linked in my signature. After going through that (and the examples), you should be able to see the MAJOR errors in your regex. If not, please ask again.

    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
    Jul 2006
    Posts
    73
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I read your article Article: Setup, Config, Test & Write mod_rewrite regex w/Examples. But I did not find what I am looking for.

    Well, this rule is working alright.
    Code:
    RewriteRule ^([^/]+)/([^/]+)/?$ /glitter1/flashdisplay.php?root=$1&cat=$2 [L]
    I just want this rule to be skipped if the url contains images.
    I have been trying to do this for the last few hours. I also tried to use RewriteCond statement, but I dont think it is going to work in my case.

    What is the syntax to specifically ignore the redirectrule if the string "images" "comes in it.

    Thanks a lot for your help.

    Nishant

  4. #4
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,680
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    Nish,

    If "I just want this rule to be skipped if the url contains images," then insert the following code before your RewriteRule:
    Code:
    RewriteCond %{REQUEST_URI} !images
    Note that this code merely looks at the {REQUEST_URI} string (URL without the domain name or query string) and tries to match the 'images' string within, i.e., not anchored at the start or at the end.

    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

  5. #5
    SitePoint Enthusiast
    Join Date
    Jul 2006
    Posts
    73
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    RewriteCond %{REQUEST_URI} !(images)
    RewriteRule ^([^/]+)/([^/]+)/?$ /glitter/flashdisplay.php?root=$1&cat=$2 [L]
    Hi,

    I tried this code. Its working!!

  6. #6
    SitePoint Enthusiast
    Join Date
    Jul 2006
    Posts
    73
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks!

  7. #7
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,680
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    Nish,

    Now, if you were more specific about the contents of your character ranges, i.e., [a-z] for lowercase characters, [A-Z] for UPPERCASE characters, [0-9] for digits, etc, that would be far more effective (and get rid of some garbage that could be matched).

    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

  8. #8
    SitePoint Enthusiast
    Join Date
    Jul 2006
    Posts
    73
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi, dk.

    "if you were more specific about the contents of your character ranges, i.e., [a-z] for lowercase characters, [A-Z] for UPPERCASE characters, [0-9] for digits, etc".
    Where do you suggest should I make changes?

    Thank you so much!

    Nishant

  9. #9
    SitePoint Enthusiast
    Join Date
    Jul 2006
    Posts
    73
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi, dk.

    I was facing a funny problem. When I enter this url in the browser(i have not put a slash after halloween)- http://www.wishafriend.com/ct/halloween

    The url automatically converts to- http://www.wishafriend.com/ct/halloween/?cat=halloween

    This thing works well if there is a slash after halloween.

    Do you have any idea why this is happening.

    Regards,

    Nishant

  10. #10
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,680
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    nish,
    Code:
    RewriteCond %{REQUEST_URI} !(images)
    RewriteRule ^([^/]+)/([^/]+)/?$ /glitter/flashdisplay.php?root=$1&cat=$2 [L]
    If you're still using this code, I'd have to say that you SHOULD be redirected but only to /glitter/flashdisplay.php?root=ct&cat=halloween which would then redirect to ... itself! That's why I dislike (.*) so much (looping) and your use of [^/]+ is only a little better (you require one or more of anything which is NOT a / vs zero or more of anything). Try adding a . (dot character) to the second range definition ([^/.]+) and see if that does.

    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


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
  •