Redirect Root to index.php

Using a single web hosting account to host multiple sites

Redirect Root to index.php

Postby pmc221 » Tue Jul 08, 2008 10:43 am

Hello everyone,

I have a bit of a strange request. I'm trying to redirect every instance of the regular domain to index.php (reverse of index.php to root). I have this:

Code: Select all
rewriteEngine On
rewriteCond %{REQUEST_FILENAME} -f [OR]
rewriteCond %{REQUEST_FILENAME} -d
rewriteRule ^(.+) - [PT,L]
rewriteRule ^(.*) index.php


But it's not doing what I need it to do. Instead of http://www.domain.com it should go to http://www.domain.com/index.php.

Any ideas?
pmc221
 
Posts: 4
Joined: Tue Jul 08, 2008 10:38 am

Postby richardk » Wed Jul 09, 2008 1:43 pm

Where are you putting it?

Try
Code: Select all
Options +FollowSymlinks

RewriteEngine On

RewriteCond %{SCRIPT_FILENAME} -f [OR]
RewriteCond %{SCRIPT_FILENAME} -d
RewriteRule ^/.+$ - [PT,L]

RewriteRule ^/.*$ /index.php [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby pmc221 » Wed Jul 09, 2008 1:51 pm

It will go in the root directory.
pmc221
 
Posts: 4
Joined: Tue Jul 08, 2008 10:38 am

Postby richardk » Wed Jul 09, 2008 2:21 pm

In a .htaccess file, then try
Code: Select all
Options +FollowSymlinks

RewriteEngine On

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

RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule . /index.php [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby pmc221 » Wed Jul 09, 2008 3:50 pm

Thanks, but it does not redirect the domain to the index.php file. Any ideas?
pmc221
 
Posts: 4
Joined: Tue Jul 08, 2008 10:38 am

Postby richardk » Wed Jul 09, 2008 3:52 pm

Do you want the URL to change? Try
Code: Select all
Options +FollowSymlinks

RewriteEngine On

RewriteRule ^$ /index.php [R=301,L]

RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule . /index.php [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby pmc221 » Wed Jul 09, 2008 3:55 pm

Perfect! Thanks! :P
pmc221
 
Posts: 4
Joined: Tue Jul 08, 2008 10:38 am


Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 19 guests

cron