bluegman991 Posted August 22, 2010 Share Posted August 22, 2010 ok in my htaccess file this is the line i am having problem with RewriteRule ^page\/(\d{0,5})\/?\-?(.*)?$ /page\.php?q1=$1&q2=$2 so as u can see by looking at it the url the page accessor will see is "http://www.website.com/page/(int)/" and the url the server see's is "http://www.website.com/page.php?q1=(int)" first of all everything works fine as is ...unless i enter a question mark somewhere in the url after the (int) then nothing after the question mark is captured my problem is at the highlighted & underlined part of the line "RewriteRule ^page\/(\d{0,5})\/?\-?(.*)?$ /page\.php?q1=$1&q2=$2" i want to change it to \? but when i do that nothing after that point is captured any other charcter works just fine just not the question mark is there something at that point i am doing wrong? is there something in apache that may be configured wrong? can apache just not handle "?" in the input url? (will i have to just find some other character to use?) Quote Link to comment Share on other sites More sharing options...
rulerofzu Posted August 23, 2010 Share Posted August 23, 2010 Through my fuzzy head from drinking too much last night 8o ....looks a bit long winded that rule. RewriteRule ^page/([A-Za-z0-9-]+)/([0-9]+)/?$ page.php?q1=$1&q2=$2 You might not need the A-Za-z Quote Link to comment Share on other sites More sharing options...
Zeggy Posted August 23, 2010 Share Posted August 23, 2010 What kind of url do you want to match? I don't understand why you will have a ? after the (int) part. Can you show some examples of urls you want to match and not match? Quote Link to comment Share on other sites More sharing options...
bluegman991 Posted August 23, 2010 Author Share Posted August 23, 2010 the question mark will be for query's the real url will be... "http://www.website.com/page/(int)/?query=foo&query2=bar" => "http://www.website.com/page.php?number=(int)&query=foo&query2=bar" or "http://www.website.com/page/(int)/" => "http://www.website.com/page.php?number=(int)" Quote Link to comment Share on other sites More sharing options...
Haunted Dawg Posted August 24, 2010 Share Posted August 24, 2010 RewriteRule ^page/([^/]+)/([^/]+) /page.php?q1=$1&q2=$2 [NC] should work. Quote Link to comment Share on other sites More sharing options...
bluegman991 Posted August 24, 2010 Author Share Posted August 24, 2010 im echoing $_GET['q2'] to make sure its working write and haunted dawg i tried what you said and........... when i have nothing after the 2nd slash it echo's .php if something does come after the 2nd / it echo's that unless there's a question mark in it. then it either ignores anything after the question mark or if the question mark is at the begining it echo's .php Quote Link to comment Share on other sites More sharing options...
Zeggy Posted August 25, 2010 Share Posted August 25, 2010 Try this: RewriteRule ^page\/([0-9]+)\/\?(.+)$ /page\.php?q1=$1&$2 RewriteRule ^page\/([0-9]+)\/(.*)$ /page\.php?q1=$1 Matches: page/(int)/ => page.php?q1=(int) page/(int)/bla => page.php?q1=(int) page/(int)/?bla=bla => page.php?q1=(int)&bla=bla Quote Link to comment Share on other sites More sharing options...
bluegman991 Posted August 25, 2010 Author Share Posted August 25, 2010 ok ive been reading around and have found out you cant escape ? in htaccess with \? you have to do something with %{QUERY_STRING} still looking to see how to make this work :thumbup: Quote Link to comment Share on other sites More sharing options...
Zeggy Posted August 25, 2010 Share Posted August 25, 2010 Ah, yes. Somebody gave a similar answer here: http://stackoverflow.com/questions/1337152/htaccess-querystring-rewrite Quote Link to comment Share on other sites More sharing options...
bluegman991 Posted August 25, 2010 Author Share Posted August 25, 2010 ok i got it working will post a working version in a sec :thumbup: Quote Link to comment Share on other sites More sharing options...
bluegman991 Posted August 25, 2010 Author Share Posted August 25, 2010 RewriteRule ^page\/([0-9]{0,5})\/$ /page\.php?q1=$1&%{QUERY_STRING} thanx for the help guys and gals :thumbsup: Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.