How to hide file name and .extention using htaccess

Hi , I have two urls. I have written them below

1.<a href=”index.php?software=ture”>Software</a>
2.<a href=”index.php?contact=ture”>Contact</a>

What i want to do is that I need to remove the file name and .extention from both of the urls. I am using wamp server on windows xp.
My url should be like this in the addressbar,
1.Mydomain/?software=ture.
2.Mydomain/?contact=ture .

I have heared about htaccess. But I don’t know how to do that.
I have witten my full code below.


  
```php

  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
&lt;title&gt;Untitled Document&lt;/title&gt;
&lt;style type="text/css"&gt;
&lt;!--
.container {
	margin: auto;
	width: 960px;
}

.bg {
	margin: auto;
	width: 960px;
}
.bg .wrapper {
	background-color: #FFCCFF;
}
--&gt;
&lt;/style&gt;

&lt;/head&gt;

&lt;body&gt;
&lt;div class="container"&gt;
&lt;div class="bg"&gt;
  &lt;div class="wrapper"&gt;
  	&lt;a href="index.php?page=software"&gt;Softwares&lt;/a&gt; | &lt;a href="index.php?page2=contact"&gt;Contact&lt;/a&gt;
  &lt;/div&gt;

&lt;/div&gt;

	&lt;?php
		$software = $_GET['page'];
		$contact = $_GET['page2'];
		if($software)
		{
			include("software/software.php");
		}
		else if($contact)
		{
			include("contact/contact.php");
		}
	?&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;




Please any body help me.

Thanks in advance.:rofl:

Hi
To rewrite te url, you need .htaccess with mod-rewrite.
Try this code in .htaccess:


Options +FollowSymLinks
RewriteEngine On

# Incepe comanda pt. mod-rewrite

RewriteRule ^?([a-zA-Z0-9=_-]+)$ index.php?$1 [NC,L] 

Also, rewrite the new url in your php code.

Hi, I tried the below url.


Options +FollowSymLinks
RewriteEngine On

# Incepe comanda pt. mod-rewrite

RewriteRule ^?([a-zA-Z0-9=_-]+)$ index.php?$1 [NC,L]

I got some errors like…


Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, admin@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

I couldn’t run the code successfully.

Hi,
Try with this code:


Options +FollowSymLinks
RewriteEngine On

RewriteRule ^/?$ /index.php [QSA,L]

Or someone more experienced can help.

Hi i tried the below code.


 Options +FollowSymLinks
RewriteEngine On

RewriteRule ^/?$ /index.php [QSA,L]

it works. but i couldn’t hide index.php in the addressbar

when i click my anchar tag it displays url like “http://localhost/myfolder/index.php?page=true” in the addressbar.

what i need is that the url should be like http://localhost/myfolder/?page=true when i click the anchar tag.

Replace the link in the anchor tab too.
If not works, i not know other way, maybe someone else.

Some hosts configure their servers to NOT serve the / but they’re relatively rare.

My advice is to LINK to /?querystring (although I hate that because it forces Apache to go find the first DirectoryIndex and serve that) as your link rather than try to force your server to remove the name of the file it’s to serve.

Regards,

DK