How to hide query string in url with .htaccess
Hello...
Good Morning All...
How to hide all query strings in my url and here i can't use hidden variables for these all because in all times i couldn't send them with form submission..And my page is having four query strings to be sent...
If any body have any clues or information about this...
Please i request you to place here...
Thanks in Advance...
Shanti.
Shanti C
Posting Virtuoso
1,642 posts since Jul 2008
Reputation Points: 137
Solved Threads: 162
Do you meen something like sessions . Sessions will allow you to pass variables between pages and are very simple to use. Simple place at the very top of your pages that use sessions the following code:
<?
session_start();
Then below is an example of how to use the session array:
<?
session_start();
$_SESSION['variable_name']='apple';
$_SESSION['testing']='orange'.
?>
<a href='page2.php'>Page 2</a>
Then page2.php
<?
session_start();
echo $_SESSION['variable_name'];
echo " is different to a ";
echo $_SESSION['testing'];
?>
cwarn23
Occupation: Genius
3,033 posts since Sep 2007
Reputation Points: 413
Solved Threads: 259
No...
thanks for your quick reply...
Is it possible with rewriting concept...
And one more thing..
should i use only one .htaccess file to access all of my folders in mysite.. And how to use rewrite conditions..
Thanks in advance...
Shanti C
Posting Virtuoso
1,642 posts since Jul 2008
Reputation Points: 137
Solved Threads: 162
You could just use form method POST
ShawnCplus
Code Monkey
1,583 posts since Apr 2005
Reputation Points: 526
Solved Threads: 268
checkout the apache.org mod_rewrite tutorials
almostbob
Posting Sensei
3,149 posts since Jan 2009
Reputation Points: 571
Solved Threads: 376
thanks for all inputs..
Any more clear information about this????
I am struggling about this....
Shanti C
Posting Virtuoso
1,642 posts since Jul 2008
Reputation Points: 137
Solved Threads: 162
Well I just don't see how it is possible to use a htaccess file to hide the url info unless you have a dedicated virtual file for each possible input variable.
cwarn23
Occupation: Genius
3,033 posts since Sep 2007
Reputation Points: 413
Solved Threads: 259
unless you have a dedicated virtual file for each possible input variable. Means???
Shanti C
Posting Virtuoso
1,642 posts since Jul 2008
Reputation Points: 137
Solved Threads: 162
means for each possible hidden value, there would need to be a different file path.
cwarn23
Occupation: Genius
3,033 posts since Sep 2007
Reputation Points: 413
Solved Threads: 259
Rewrite rules don't actually hide the query string. Rewrite rules pretty much convert seo friendly urls into the actual query string.
Example .htaccess:
RewriteEngine on
RewriteRule ([^/\.]+)/?.html$ viewPage.php?ID=$1 [L]
The above rewrite rule will allow you to do something like this:
url reads: yoursite.com/DaniWeb.html
apache interprets as: yoursite.com/viewPage.php?ID=DaniWeb
Therefore
<?php
$id=$_GET['ID'];
echo $id;
?>
will output DaniWeb.
buddylee17
Practically a Master Poster
697 posts since Nov 2007
Reputation Points: 232
Solved Threads: 137
Honestly, you have been given the proper solutions. Sending (and therefore, reading) your forms with the POST method sends variables through the headers sent. For this purpose, however, I would recommend SESSIONs as people could potentially look at the header information. SESSION variables are contained solely on the server (aside from the associated client COOKIE which only contains the SESSION ID).
Well that's a good approach except for the fact that you somehow have to get the data to the PHP script first so the data can be placed in the session :)
ShawnCplus
Code Monkey
1,583 posts since Apr 2005
Reputation Points: 526
Solved Threads: 268
thank you for all especially death_oclock, ShawnCplus, !Unreal and budleee.....
One more thing..
How to write rewrite conditions on .htaccess file...please give me some explanation rather than tutorials...
And in my site, i had written .htaccess file for every folder individually. Is it correct or not??
Tel some tips on this concept..
And quote me with 404 error solution with URL ReWriting..
Thank you so much for all.....
Shanti
INDIA.
Shanti C
Posting Virtuoso
1,642 posts since Jul 2008
Reputation Points: 137
Solved Threads: 162
And in my site, i had written .htaccess file for every folder individually. Is it correct or not??
That is sort of correct but you can also make virtual folders with .htaccess. An example is the following:
RewriteEngine on
RewriteRule *\/([^/\.]+)/?.html$ viewPage.php?ID=$1 [L]
Note that RewriteEngone on generally goes at the top of the .htaccess file and only appears once (generally). And the above example will rewrite all html files inside all subdirectories of the htaccess file to the php file.And quote me with 404 error solution with URL ReWriting.. The following code will do the trick:
ErrorDocument 404 /path/to/file.html
Don't forget the first forward slash in the above code path.
Enjoy
cwarn23
Occupation: Genius
3,033 posts since Sep 2007
Reputation Points: 413
Solved Threads: 259
thank u cwarn23 ....
what does the line ErrorDocument 404 /path/to/file.html will do?????
Shanti C
Posting Virtuoso
1,642 posts since Jul 2008
Reputation Points: 137
Solved Threads: 162
what does the line ErrorDocument 404 /path/to/file.html will do?????
It sets the error 404 (file not found) page to your custom page.
cwarn23
Occupation: Genius
3,033 posts since Sep 2007
Reputation Points: 413
Solved Threads: 259
thank you very much cwarn23 for your continues replies...
thanks all....
Shanti C
Posting Virtuoso
1,642 posts since Jul 2008
Reputation Points: 137
Solved Threads: 162