Mod Rewrite problems (problems caused by Mod Rewrites?)

Discussion in 'Apache' started by seobrien, Jan 5, 2007.

  1. #1
    Can anyone summarize potential problems for a dynamic website caused by implementing mod (url) rewrites?
    Particularly for website maintenance such as the ability to create new categories (folders of content) keeping in mind that those categories that appear in the URL now (www.website.com/category/) have been rewritten from a parameter in a dynamic structure (www.website.com/site?section=category)
    My IT resources claim they now have to code links twice

    I'm not clear why or how this could be possible. Yet it appears to coincide with the reslease of our rewrites.

    Any insights??

    Thank you!!
     
    seobrien, Jan 5, 2007 IP
  2. rodney88

    rodney88 Guest

    Messages:
    480
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I'm not entirely sure I've understood - if you're worried about site.com/realdir being rewritten when it shouldn't, you can add rewriteCond to only rewrite if the requested url is not an existing file or directory.

    RewriteCond %{SCRIPT_FILENAME} !-f
    RewriteCond %{SCRIPT_FILENAME} !-d
    RewriteRule ...#your rewrite rule here
    Code (markup):
     
    rodney88, Jan 5, 2007 IP
  3. seobrien

    seobrien Peon

    Messages:
    222
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks Rodney, I think my challenge is that I'm asking because I'm not even sure I understand

    We're running on Apache with Broadvision's content management system (DCC)
    I've received this insight that may help explain the potential problem:
    "your team may have to rewrite the links manually or else use a redirect which will mean serving 2 pages for every link clicked. Stuff like image code may have to be rewritten or you may have to create dupicate directories for the same images.

    EG: yoursite.com/site?section=category has an image located in yoursite.com/image.jpg with mod_rewrite enabled the page code looks for the image at yoursite.com/catagory/image.jpg

    you should be able to create automatic rules in Mod_rewrite that take care of everything, but its not easy."


    That explanation sounds like what is happening to us. Is there any source to which I can turn to help my IT guys figure this out? If that is possibly the problem, where can I find a guidance on how to create rules to solve it?

     
    seobrien, Jan 5, 2007 IP
  4. rodney88

    rodney88 Guest

    Messages:
    480
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    0
    #4
    The apache mod_rewrite documentation is always good for reference. The FAQ in this forum may or may not be of any help. Otherwise there are plenty of resources available elsewhere - just do a search.

    I'm afraid I still haven't been able to fully understand your problem but I think we're getting there. Is it just images that are now not showing up? If it's that requests for images are being rewritten when they shouldn't be and causing them not to be found, just add a RewriteCond that tells your RewriteRule only to do the rewrite if the requested URL (i.e. site.com/image.jpg) does not exist.

    For instance, if you've currently got something similar to:
    RewriteRule (.*) /site?section=$1
    Code (markup):
    Simply insert above:
    RewriteCond %{SCRIPT_FILENAME} !-f
    Code (markup):
    You can probably cut out having to check for the file existing and simply do it by file extension (i.e. only rewrite if there is not a jpg|gif|png file extension)... but that's for another day.
     
    rodney88, Jan 5, 2007 IP
  5. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #5
    Nintendo, Jan 5, 2007 IP
  6. seobrien

    seobrien Peon

    Messages:
    222
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #6
    We are, and this has been helpful, I'm going back to IT so no response from me until more investigation

    Thanks for the help!
     
    seobrien, Jan 8, 2007 IP