I configured my apache2 like this before:
<VirtualHost _default_:443>
...
RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteRule "^/?(.*)" "https://%{SERVER_NAME}/$1" # HTTPS auto redirect
RewriteRule "^/example/?$" "/example.json"
...
When I access example.com/example
or example.com/example/
it does shows the contents of example.com/example.json
.
Then I installed another software and it requires to access /software/web
for the main webpage, and directories other than web
shouldn't be exposed to the public. So I write this:
# DocumentRoot is /var/www/html
<Directory /var/www/html/software/>
Require all denied
AllowOverride All
</Directory>
<Directory /var/www/html/software/web/>
Require all granted
AllowOverride All
</Directory>
It works by accessing example.com/software/web
. I want to rewrite the link to omit the /web
part (so I can just type example.com/software
), so I tried to add this:
RewriteRule "^/software/?$" "/software/web"
However when I tried to access the shortened URL it give out a 403 error:
You don't have permission to access /software/ on this server.
I tried to add a trailing slash like this:
RewriteRule "^/software/?$" "/software/web/"
Then it says
You don't have permission to access /software/app.php on this server.
I tried several tweaks to the regex but no good. How to make it work? Any help is appreciated.