Page 1 of 1

Apache /index.php to / WITHOUT specific domain?

Posted: Tue Feb 24, 2009 6:00 am
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?

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

Posted: Tue Feb 24, 2009 11:48 am
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]

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

Posted: Tue Feb 24, 2009 4:11 pm
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.