Reputation: 1631
Vhost config:
<VirtualHost *:80>
ServerAdmin [email protected]
ServerAlias *.cccc.net
ServerName lolololololol.cccc.net
DirectoryIndex index.html index.php index.htm
DocumentRoot /home/someuserblabla/ccccnet
#Rewrite abc.cccc.net to ./abc (folder). (hidden rewrite, without redirect)
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(.*)\.cccc\.net$
RewriteRule ^(.*)$ /%1/$1 [L]
DirectoryIndex index.php index.htm index.html
</VirtualHost>
DNS : *.cccc.net ==> 99.99.99.99
Everything works fine.
If you enter wow.cccc.net, but there is no that folder, The server will return a 404 Not Found.
The interesting thing is: Today, I'm going to add a folder called dev(/home/someuserblabla/ccccnet/dev), but It always return a 403 error, and this problem is immediately solved when I simply rename the folder.
I double checked all config files of Apache, It seems nothing wrong, And there is no "filter" for something called "dev"
After that, I remember there is a folder call "dev" in the system root.
Then I tried etc.cccc.net root.cccc.net ....
They all return 403 error instead of 404.
My Clue Is:
There is a order for rewrite module to match the directory. It search the root folder first, then the current folder.
Is there any suggestions? I don't want it searching the root directory.
Thanks.
Upvotes: 0
Views: 135
Reputation: 776
Yes, your rewrite rule has /
as the base directory, so that's where it rewrites to. Try:
RewriteRule ^(.*)$ /home/someuserblabla/csuwnet/%1/$1 [L]
Upvotes: 1