29

How can I have the following setup in apache?

http://server/ABC/* should be served by /var/www/ABC/*

http://server/PQR/* should be served by /var/www/PQR/*

Every other request should be served by /var/www/Others/index.php (a single file).

Thanks,

JP

4

2 回答 2

25

使用别名:

Alias /ABC/ /var/www/ABC/
Alias /PQR/ /var/www/PQR/

让文档根目录指向 /var/www/Others/index.php。它可以解决问题。:)

于 2010-12-27T12:24:19.060 回答
1

You can do this with mod_alias, which is part of the apache distribution.

http://httpd.apache.org/docs/current/mod/mod_alias.html

for serving everything else with the single file you would use mod_rewrite. This has many features and depending on your needs you might need to tweak that.. but something like this should work:

RewriteEngine on
RewriteRule ^(.*)$ /index.php?path=$1 [L]

you would put that in a .htaccess file in the document root.

于 2010-12-27T12:19:40.970 回答