Question

I have a virtual host: www.example.com which contains 2 subfolders namely hello and hello2. hello contains nothing while hello2 contains a test.html file.

Now what I want to do is that whenever I access www.example.com/hello I want the page to access test.html in hello2 subfolder.

Sample output:

url: www.example.com/hello

after pressing enter,

url: www.example.com/hello2/test.html
page display: This is test.html



How am I able to do this without using .htaccess just using httpd.conf configuration. I've been stuck for hours.



Here's what I've tried but no luck

<VirtualHost *:80>
        DocumentRoot /var/www/www.example.com/hello
        ServerName www.example.com
        ServerAlias www.example.com
        Alias /hello /var/www/www.example.com/hello2
        <Directory /var/www/www.example.com/hello2>
            #Options FollowSymLinks
            Options Indexes FollowSymLinks Includes ExecCGI
            AllowOverride All
            Order deny,allow
            Allow from all
            RewriteEngine on
            RewriteRule ^/index\.html$ test.html [R]
        </Directory>
</VirtualHost>

Thank you in advance.

Was it helpful?

Solution

I figured out putting this in the httpd.conf

<VirtualHost *:80>
        DocumentRoot /var/www/example.com
        ServerName www.example.com
        ServerAlias www.example.com
        Alias /hello /var/www/www.example.com/hello2
        RewriteEngine On
        Redirect 301 /hello http://www.example.com/hello2/test.html
</VirtualHost>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top