0

I am new to apache and webservers in general but I have a problem with accessing phps with alias URLs from the web. This is what my config looks like:

ServerAdmin something@gmail.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com

AliasMatch "^/index$" "/"
AliasMatch "^/about$" "/about.php"
AliasMatch "^/editor$" "/editor.php"

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

The php files that I want to display are located in DocumentRoot folder, and I've made sure root and all its subdirectories and files have permissions 755. What confuses me is that instead of Alias I use Redirect it works fine, except that the browser URL field shows .php which is not desirable. So how come permission is not granted with aliasing but with redirecting? Below is a log entry of attempting to access with site conf file as written above:

127.0.0.1 - - [27/Jan/2017:04:11:55 +0100] "GET /about HTTP/1.1" 403 422 "http://example.com/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36"

Any help is appreciated, Cheers

Daniel N
  • 53
  • 1
  • 11

1 Answers1

1

You should use the full path for the target:

AliasMatch "^/index$" "/var/www/example.com/"
AliasMatch "^/about$" "/var/www/example.com/about.php"
AliasMatch "^/editor$" "/var/www/example.com/editor.php"

In this case, the simpler Alias is also valid:

Alias "/index" "/var/www/example.com/"

etc.

References

Jannes Botis
  • 11,154
  • 3
  • 21
  • 39