简体   繁体   中英

Alias an URL in Apache in order to route requests on a certain URL through a PHP-script

I am using Apache 2.2.6 with suPHP 0.6.2 and PHP 5.2.6 and I am trying to use an Alias in order to route all requests on a certain URL trough a PHP script. I want all requests to /test to go through index.php. In the Apache virtualhost config I have set up an Alias Alias /test /index.php . index.php is just a dummy script containing the following:

<?php
phpinfo();
?>

Requesting http://localhost/index.php works and gives the expected output, however requesting http://localhost/test does not and gives me a 403 error, the error.log contains the following:

[Wed Jan 27 17:13:19 2010] [error] [client 127.0.0.1] client denied by server configuration: /index.php

What is wrong with my Alias?

Edit: I almost forgot to mention that rewriting /test to /index.php through mod_rewrite works as well, however I want to avoid mod_rewrite on my production server if possible.

Alias需要绝对路径,因此Alias /test /var/www/index.php使其起作用。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM