Hello I've just started using Apache webserver on my ubuntu home server. I want to start redirecting access to my directories under /var/www/ to a login page (/var/www/login.php). I googled online to see how I could do this and came across information about using redirects on apache server with a .htaccess file that contains the redirect paths. I was unsuccessful in my attempts. Is this the best way or is there another alternative. Any help is much appreciated. Thanks Contents of my apache webserver config file: XG15@XG15-Home:/etc/apache2/sites-available$ cat xg15.xg15serve.net | more <VirtualHost *> ServerAdmin xg15@xg15.xg15serve.net ServerName sd12.selfip.net ServerAlias www.xg15.xg15serve.net DocumentRoot /var/www/ <Directory /> Options FollowSymLinks #AllowOverride None AllowOverride All </Directory> <Directory /var/www/> Options Indexes FollowSymLinks MultiViews #AllowOverride None AllowOverride All Order allow,deny allow from all </Directory> ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all </Directory> ErrorLog /var/log/apache2/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog /var/log/apache2/access.log combined Alias /doc/ "/usr/share/doc/" <Directory "/usr/share/doc/"> Options Indexes MultiViews FollowSymLinks AllowOverride None Order deny,allow Deny from all Allow from 127.0.0.0/255.0.0.0 ::1/128 </Directory> </VirtualHost> Contents of .htacess file: XG15@XG15-Home:/var/www$ sudo cat .htaccess [sudo] password for XG15: #Aliases/Redirects redirect 301 /var/www/directory1 /var/www/login.php
in httpd.conf add RewriteEngine On RewriteRule http://www.domain.com/directory http://www.domain.com/login.php [R] Code (markup): or <VirtualHost dot.dot.dot.dot> ServerName site.com ServerAlias www.site.com/directory1 ServerAlias www.site.com/directory2 Redirect / http://www.site.com/login.php </VirtualHost> Code (markup): There are multiple ways, but those are the ways I would do it. I'm not sure if they will work, so make a backup of your files.