Page 1 of 1
htaccess rewrite rule
Posted: Tue Jun 08, 2010 12:49 pm
by rajsekar2u
HI,
This is the first time am using htaccess. I didn't have much knowledge in this. Please help me.
I need a rewrite rule which have to hide everything other than the site's base URL.
Eg. If the site URL is "
http://example.com/index.php?id=1"
then it should show only "
http://example.com/"
I've tried somethings but i didn't got the result.
Re: htaccess rewrite rule
Posted: Tue Jun 08, 2010 6:54 pm
by requinix
You can't hide the URL like that.
Re: htaccess rewrite rule
Posted: Wed Jun 09, 2010 5:07 am
by rajsekar2u
Hi,
Thanks for your reply.
Then is it possible to show as a folder
Re: htaccess rewrite rule
Posted: Wed Jun 09, 2010 7:56 am
by cpetercarter
I think that what tasairis means is that you cannot use .htaccess to change what appears in the address bar of the browser. You can however use it to "divert" a request for one url (eg "mysite.com/podcasts") to a different url ("mysitecom/index.php?page=podcasts").
If you want to change the address as it appears in the address bar, you need to look at Javascript.
Re: htaccess rewrite rule
Posted: Wed Jun 09, 2010 4:15 pm
by manRay
You can change what is in the address bar by not including the file extension.
ex) <a href="home"></a> It will look something like
www.yourwebsite/home in the address bar
This will bring you to a file called home in the current directory, I am not too sure how it work when there are other files with the same name but different extensions.
Hope this helps.
Re: htaccess rewrite rule
Posted: Wed Jun 09, 2010 5:07 pm
by cpetercarter
I don't think this is quite right.
http://www.mysite.com/home points to the
directory "home". If the "home" directory exists, the server will look for a file "index.html" in the home directory, or - failing that, and depending on configuration settings - it will look for "index.php". If there is no index file, the server will return a "not found" error, or will display a list of the contents of the "home" directory, again depending on config settings. If the "home" directory does not exist, the server returns a "not found" error.
Re: htaccess rewrite rule
Posted: Wed Jun 09, 2010 7:09 pm
by requinix
If you're using Apache and have the MultiViews option enabled, Apache will look for files with known extensions after checking for matching directories. Thus "/home" could refer to the /home directory or the /home.* file.
It doesn't count just any extension - it has to know about it first, like through an AddHandler or AddType directive.
Re: htaccess rewrite rule
Posted: Thu Jun 10, 2010 2:00 pm
by manRay
while on the topic, what do I change in order to be able to use index.php (instead of index.html, ie:
http://www.mysite.com) as my home page?
Re: htaccess rewrite rule
Posted: Thu Jun 10, 2010 4:29 pm
by requinix
manRay wrote:while on the topic, what do I change in order to be able to use index.php (instead of index.html, ie:
http://www.mysite.com) as my home page?
DirectoryIndex in your .htaccess. Most preferred filenames left, least preferred right.
Code: Select all
DirectoryIndex index.php index.html