Forum Moderators: phranque

Message Too Old, No Replies

.htaccess and query strings

         

paull2k

5:34 am on Mar 23, 2005 (gmt 0)

10+ Year Member



What I want to do for my site is to be able to get everything after the? using .htaccess. for example index.php?page=blah, I want to know how to get page=blah in .htaccess. hopefully someone understands my question.

jdMorgan

7:17 am on Mar 23, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



paull2k,

Welcome to WebmasterWorld!

You can use RewriteCond %{QUERY_STRING} (.*) in mod_rewrite to test and manipulate the query string.

See our forum charter [webmasterworld.com] for references.

Jim

paull2k

7:55 am on Mar 23, 2005 (gmt 0)

10+ Year Member



Hmm, unfortunately I thought through the problem I was having before, but I don't think that was what I really needed...
What I really need is this, when someone tries to access any page in [example.com...] it will redirect them to [example.com...] I know I could do it with a bunch of redirect lines, but I want it to be able to automatically get the page name and send them on their way to the proper address.

HughMungus

8:00 am on Mar 23, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I do this.

Try this: RewriteRule ^([0-9]+)/?$ /whatever.php?variablename=$1 [QSA,L]

In my case (and example) if someone types in [widgets.com...] it redirects (seamlessly) to [widgets.com...]

In my case, I'm using numbers instead of words.

paull2k

8:06 am on Mar 23, 2005 (gmt 0)

10+ Year Member



HughMungus,
I unfortunately did not understand how you did that at all. I guess I should have mentioned I'm not very good with .htaccess, I'm actually fairly new to it. Any assistance you could give me would be appreciated. Thanks. Also, in any case. The RewriteRule doesn't seem to be working at all. not getting any errors, just a 404 not found error saying it can't find the specified file.

[edited by: paull2k at 8:10 am (utc) on Mar. 23, 2005]

HughMungus

8:09 am on Mar 23, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm not that experienced with it. I just learned what I needed to know for it to work in my specific case. Here's a very useful page: [httpd.apache.org...]

paull2k

8:15 am on Mar 23, 2005 (gmt 0)

10+ Year Member



I have looked at that page many times in the past, and cannot understand at all how RedirectMatch works. If I could find some documentation that explained it further, perhaps then I could work with it.

All I need is for it to redirect /page/xx to /?page=xx, without having to add several lines for each separate page