Redirect a subdomain to a specific directory using .htacces
I had a problem before and asked this question: Uploading PHP image using POST
I found out that my domain redirect was causing this problem. I used redirection (server emulation) on my domain panel which is unable to handle file uploads.
While looking for a solution, I found this: subdomain directory redirection with htaccess
I have included mod_rewrite module and tried this .htacces file:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^subdomain\.domain\.de$
RewriteRule ^(.*)$ http://domain.de/sub/directories/$1 [R=301,L]
subdomain.domain.de has A-DNS record set to my server IP. My server root directory needs authentication, but the directory I want the subdomain to point to does not. I'm not sure if the redirect works, but when I open the subdomain it asks for authentication.
How can I redirect a subdomain to a different directory on the server without having the right to authenticate the user?
source to share
I was able to do what I wanted using virtual hosts by following this tutorial: https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-14- 04-lts
I also had to delete the .htaccess file. Apart from changing the ServerAlias โโ/ Name and DocumentRoot in the new config file available for sites, I had nothing to change.
source to share