danmerrino Posted October 1, 2008 Share Posted October 1, 2008 hello you helpful nerds ( ), i have lately started playing around with the htaccess files and i have learned how to rewrite urls and some other basic things but now i was wondering if the htaccess file has access to the variables being passed from one page to another via the POST method? i have been looking for information about this on these here internets but somehow havent found anything i would greatly appreciate any helpful suggestions or tips, greetings, dan Quote Link to comment https://forums.phpfreaks.com/topic/126623-htaccess-and-post-variables/ Share on other sites More sharing options...
trq Posted October 1, 2008 Share Posted October 1, 2008 now i was wondering if the htaccess file has access to the variables being passed from one page to another via the POST method? No. A .htaccess file is simply a local configuration file. The only reason mod_rewrite gets access to the GET varaibles is because they are within the url. Quote Link to comment https://forums.phpfreaks.com/topic/126623-htaccess-and-post-variables/#findComment-654776 Share on other sites More sharing options...
danmerrino Posted October 1, 2008 Author Share Posted October 1, 2008 thanks for your promt answer and for destroying all my hopes and dreams :'(. Quote Link to comment https://forums.phpfreaks.com/topic/126623-htaccess-and-post-variables/#findComment-654787 Share on other sites More sharing options...
trq Posted October 1, 2008 Share Posted October 1, 2008 What exactly are you trying to do? Quote Link to comment https://forums.phpfreaks.com/topic/126623-htaccess-and-post-variables/#findComment-654789 Share on other sites More sharing options...
danmerrino Posted October 2, 2008 Author Share Posted October 2, 2008 well basically i am trying to have 1) search results displayed on a page whos url i rewrite with the mod_rewrite in htaccess and i would like this url to be only structured like domain.com/search/query/order/page etc., meaning without it containing any name=value pairs 2)and i would also like for one to be able to copy paste this url but still get the desired results 3) and i also dont want to use any js for this functionality. the way i am doing it right now is by passing the query to the same page via post and catching it at the very top with something like if(isset(POST[query])) header(location:search/query); so the page needs to reload and then redirect. Not very elegant somehow. since i am not exactly what you would call an experienced programmer i have been struggling to find another solution and i was thinking about accessing the POST[query] in the htaccess file then sending the client something like search/query and then using this last part of the url in my query string something along those paths. Quote Link to comment https://forums.phpfreaks.com/topic/126623-htaccess-and-post-variables/#findComment-655432 Share on other sites More sharing options...
trq Posted October 2, 2008 Share Posted October 2, 2008 Sounds to me like you need to be using GET not POST. Quote Link to comment https://forums.phpfreaks.com/topic/126623-htaccess-and-post-variables/#findComment-655507 Share on other sites More sharing options...
danmerrino Posted October 2, 2008 Author Share Posted October 2, 2008 yes, but risking sounding like a noob: i think that the only way to pass variables with the get method is by passing them in the url in name value pairs, meaning that i would get a url like domain.com/search?q=solution+to+problem in the address bar, when what i really want, is domain.com/search/solution+to+problem. but to be honest if i think about it like a logical person i have to realize: there is just no way to modify the url of the result page that will receive the query according to the users query without some sort of client side programming or reloading of the site from which the query is being made. Damnit. but thanks for your suggestions greetings, dan Quote Link to comment https://forums.phpfreaks.com/topic/126623-htaccess-and-post-variables/#findComment-655554 Share on other sites More sharing options...
trq Posted October 2, 2008 Share Posted October 2, 2008 Ah, now I see what your getting at. You could do something like this.... <html> <head> <title>search</search> </head> <body> <form action="/search<?php echo isset($_POST['query']) ? '/' . $_POST['query'] : ''; ?>" method="post"> <input type="text" name="query"> <input type="submit" name="submit"> </form> <?php if (isset($_POST['submit'])) { // display your search results. } ?> </body> </html> Would need alot more work but it might give you some ideas. Quote Link to comment https://forums.phpfreaks.com/topic/126623-htaccess-and-post-variables/#findComment-655562 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.