1

suppose i have a file like this on my site:

example.com/pages/live_report.php 

and now i want when a user typed url live.example.com, it refer to above file without i to be force rename it.

how can i do that via htaccess ?

of course i try this rule that is recommended on Redirect a subdomain to a directory using .htaccess :

RewriteEngine On RewriteCond %{HTTP_HOST} ^live\.example\.com RewriteRule ^(.*)$ /pages/live_report.php$1 [L] 

but this do not work

2 Answers 2

2

If it doesn't work at all, you many not have 'AllowOverride All' in the vhost file. Try something like

deny from all 

to see if .htaccess is being processed

If you're getting redirected to http://live.example.com/pages/live_report.php you need to use a full URI, eg

RewriteEngine On RewriteCond %{HTTP_HOST} ^live\.example\.com RewriteRule ^(.*)$ http://www.example.com/pages/live_report.php$1 [L] 
Sign up to request clarification or add additional context in comments.

3 Comments

i do not want redirect live.example.com to that file just it is a rewrited url for live.example.com/pages/live_report.php however i test you rule in chrome but show not found error
yes it is correct. but a note:Already when i create a new sub domain via cpanel this message is shown and after A few hours it was correct and work fine. Is it possible that it Is caused this problem
of course, it takes a few hours for the new DNS record to propagate
0

Maybe this will help (not tested):

RedirectMatch 301 ^/folder http://www.mydomain.com/file.html 

or this:

RedirectMatch 301 ^/folder(.*) http://www.mydomain.com/file.html 

1 Comment

but when you have the sub domain, it has a landing directory? Put .htaccess there

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.