Please help mod_rewrite not passing arguments

Discussion in 'Apache' started by robbyc, Mar 2, 2007.

  1. #1
    Hi I have the following in my .htaccess file

    Yet the arguments do not seem to work. My webservice just says please specify a method which means that the m parameter is not set.

    Any suggestions this is driving me insane
     
    robbyc, Mar 2, 2007 IP
  2. clixxer

    clixxer Peon

    Messages:
    47
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I think ^geors is the problem. What happens if you take out the '^'?
     
    clixxer, Mar 2, 2007 IP
  3. rodney88

    rodney88 Guest

    Messages:
    480
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I have had issues with including the dash in the range of characters to match in the past. It may be worth a shot replacing:
    ([A-Za-z0-9-]+)
    with
    ([A-Za-z0-9]|-)+
     
    rodney88, Mar 2, 2007 IP
  4. robbyc

    robbyc Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Hi tried both those things and it hasn't helped.

    It is definitely matching but the arguments don't seen to be being passed.

    I was simply copying from the http://http://www.ilovejackdaniels.com/apache/mod_rewrite-cheat-sheet/

    It may help if I explain exactly what I am trying to do. I am doing a project at uni creating a web service for geocoding items in RSS feeds, it is written in object orientated php and is accessed through robs.homeftp.net/georss.php .
    This can take a large number of arguments mostly for debugging and so when I have to demo it I can show my supervisor how it works.

    Currently it is accessed like the following
    http://robs.homeftp.net/georss.php?m=m&ch=NWS&noWords=2000&noSurnames=90000&url=http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/northern_ireland/rss.xml

    but I want to make this much nicer as for users of the service (once it is finished) will only need to specify the url.

    So any suggestions are welcome. I have just realised when writing this that the url will never match as it also contains slashes.
     
    robbyc, Mar 2, 2007 IP
  5. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #5
    Post an original URL, and how you want it.
     
    Nintendo, Mar 2, 2007 IP
  6. robbyc

    robbyc Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Original URL

    http://robs.homeftp.net/georss.php?m=m&ch=NWS&noWords=2000&noSurnames=90000&url=http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/northern_ireland/rss.xml

    How I "think" I want it

    http://robs.homeftp.net/georss/http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/northern_ireland/rss.xml

    or maybe

    http://robs.homeftp.net/georss-http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/northern_ireland/rss.xml

    something like that
     
    robbyc, Mar 3, 2007 IP
  7. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #7
    Only way to get that URL is if the shorter URL
    http://robs.homeftp.net/georss.php?...ewsonline_uk_edition/northern_ireland/rss.xml
    would also work, and your sites down right now.

    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^m/([^.]+)/ch/([^.]+)/noWords/([^.]+)/noSurnames/([^.]+)/url/([^.]+)\.html$ georss.php?m=$1&ch=$2&noWords=$3&noSurnames=$4&url=$5 [L]
    RewriteRule ^georss/([^.]+)\.html$ georss.php?url=$1 [L]

    Second line is the code if the short URL does work, first RewriteRule line if it doesn't. You'll have to have the other stuff in the URL if it doesn't.
     
    Nintendo, Mar 3, 2007 IP
  8. rodney88

    rodney88 Guest

    Messages:
    480
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    0
    #8
    You could just hardcode those extra values into the second rewriterule there. But if you're going to do that, it's probably just as easy to alter the script to contain default values, which are replaced by values from the URL if set.
     
    rodney88, Mar 4, 2007 IP
  9. robbyc

    robbyc Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    yeah in the end I altered some scripts that were relying on the current default values and made it so I just needed to call /?url=the.url.com

    Thanks for your help
     
    robbyc, Mar 5, 2007 IP