Jump to content

htaccess and POST variables


danmerrino

Recommended Posts

hello you helpful nerds ( ;D),

 

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.