siniradam
siniradam

Reputation: 2929

Redirect all subdomains to a file except existing files

What I try to achieve is, how can I alias all subdomains to a file except existing files,

The code below, with hashs working but I can't access to files, files also redirecting to "site.php" But when I remove the hashs then condition is not working. What is the correct way

RewriteCond %{HTTP_HOST} !=example.com
RewriteCond %{HTTP_HOST} !=www.example.com
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . site.php [L]

Upvotes: 0

Views: 40

Answers (1)

arco444
arco444

Reputation: 22881

Try this:

RewriteCond %{HTTP_HOST} !^example\.com
RewriteCond %{HTTP_HOST} !^www\.example\.com
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* /site.php [L]

I've omitted the directory check as you specified everything except existing files

Upvotes: 1

Related Questions