Reputation: 205
I have the following link. elad.test.com/test.php I would like to be able to typ elad.test.com and get to that URL. I know I have to do it with .htaccess but it doesn't work for me.
can someone please assist?
Upvotes: 0
Views: 3545
Reputation: 143906
If you're only hosting 1 virtual host, you can omit the RewriteCond. In your .htaccess file add in an appropriate place:
RewriteCond %{HTTP_HOST} ^elad\.test\.com$ [NC]
RewriteRule ^$ /test.php [L]
This will make it so if you type http://elad.test.com/ in your location bar in your browser, you'll get the /test.php page (but your browser's location bar won't change).
Upvotes: 0
Reputation: 53208
You need to add test.php
to be the first load order for the test
subdomain:
DirectoryIndex test.php index.php index.html index.htm default.htm
Upvotes: 1
Reputation: 523
if you do not want to use the .htaccess file, you can always use and index.php file that redirects to the test.php using
header("location: test.php");
Alternatively, if you want your browser to redirect to test.php instead of index.php when you request a directory (ie elad.test.com/ - which is the index directory of the server), you can do from by changing the apache configuration. Note that this will affect every directory in the server.
Upvotes: 2
Reputation: 5377
Create a index.php (or whatever your default file is called) file and use it to redirect to your test.php file.
Sample:
<?php
header('Location: http://elad.test.com/test.php');
exit;
?>
See http://php.net/manual/en/function.header.php
Upvotes: 0