Go Back   CodingForums.com > :: Server side development > Apache configuration

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-02-2013, 07:32 PM   PM User | #1
doubledee
Regular Coder

 
doubledee's Avatar
 
Join Date: Mar 2011
Location: Arizona
Posts: 640
Thanks: 20
Thanked 0 Times in 0 Posts
doubledee has a little shameless behaviour in the past
Removing index.php

How do I create a mod_rewrite so that if my website is accessed via....

http://local.debbie/index.php

...then things get rewritten to...

http://local.debbie


(While testing my website, my code seems to be working properly, but when I first launch "index.php" I don't want to see it. And, of course, the same behavior should apply when my website is on the Internet.)

Thanks,


Debbie
doubledee is offline   Reply With Quote
Old 03-04-2013, 12:30 AM   PM User | #2
durangod
Senior Coder

 
Join Date: Nov 2010
Posts: 1,191
Thanks: 217
Thanked 31 Times in 30 Posts
durangod is on a distinguished road
From my experience index files wether it be .html .htm .php or what have you, are requried by default and the server will look for these files in a certain order from a list of about 26 options.

Now i have seen empty index.php files in dir before and i am not sure if that is required to do this next step or not.

But you can specify in your .htaccess file the file name you want to use as your top tier file instead of an index.

some thing like this in your .htaccess

Code:
DirectoryIndex something.html
Which the server will now look for that file name and will longer look for any other name as the index.

This was my source as i have not done this before so if you want to refer to this here ya go..

http://support.tigertech.net/index-file-names
durangod is offline   Reply With Quote
Old 03-04-2013, 02:19 PM   PM User | #3
Rowsdower!
Senior Coder

 
Rowsdower!'s Avatar
 
Join Date: Oct 2008
Location: Some say it's everything.
Posts: 2,015
Thanks: 5
Thanked 395 Times in 388 Posts
Rowsdower! has a spectacular aura aboutRowsdower! has a spectacular aura aboutRowsdower! has a spectacular aura about
This can be done:

Code:
RewriteCond %{THE_REQUEST} ^.*/index.php 
RewriteRule ^(.*)index.php$ /$1 [R=301,L]
This redirects anyone trying to access index.php (in any directory at or above the location of the .htaccess file containing this rule) back to the folder in which the index.php file is meant to be located.

So this:
http://www.example.com/some/folder/index.php
should rewrite to this:
http://www.example.com/some/folder/

and this:
http://www.example.com/index.php
should rewrite to this:
http://www.example.com/

...and so on.
__________________
The object of opening the mind, as of opening the mouth, is to shut it again on something solid. –G.K. Chesterton
See Mediocrity in its Infancy
It's usually a good idea to start out with this at the VERY TOP of your CSS: * {border:0;margin:0;padding:0;}
Seek and you shall find... basically:
validate your markup | view your page cross-browser/cross-platform | free web tutorials | free hosting
Rowsdower! is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:49 AM.


Advertisement
Log in to turn off these ads.