Apache /index.php to / WITHOUT specific domain?

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Apache /index.php to / WITHOUT specific domain?

Post by JAB Creations »

I've seen plenty of working examples of Apache redirects to change /index.php to just / however they always include a static domain name. Has any one come across the same script they could please share so I don't have to create a separate .htaccess file for my local and live environments?
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Re: Apache /index.php to / WITHOUT specific domain?

Post by JAB Creations »

This sort of works though it doesn't retain the sub-directory (so http://localhost/error/index.php simply redirects to http://localhost/ in example instead of http://localhost/error/). Here is what I have...

Code: Select all

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.php\ HTTP/
 
RewriteRule ^index\.php$ http://%{SERVER_NAME} [R=301,L]
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Apache /index.php to / WITHOUT specific domain?

Post by Chris Corbyn »

If you want to have multiple sites on localhost:

1. Add an entry to your hosts file that points 127.0.0.1 to some other imaginary domain (other-site.webdev ?)
2. Create a VirtualHost in Apache for this domain
3. Open http://other-site.webdev in your browser... voila!

Now you can have as many sites on your hard disk as you like.
Post Reply