在Apache上使用参数和基于Django的配置提供PHP脚本
问题描述:
I have the following setup for my Django based website:
<VirtualHost 10.0.0.4>
DocumentRoot "/home/joel/www"
<Directory "/home/joel/www">
Order allow,deny
Allow from all
</Directory>
WSGIScriptAlias / "/home/joel/www/app.wsgi"
Alias /book /php/book.php?id=1
ServerName mysite.local
</VirtualHost>
I would like to serve a PHP script when someone access mysite.local/book
which is located at /php/book.php
. This works fine if I don't want to send parameters to the script (i.e. Alias /book /php/book.php
). However, when i try to send a parameter such as id=1
it fails. How can I achieve this redirection with the configuration file above?
Thanks,
Joel
答
Don't use alias, but mod_rewrite:
RewriteEngine On
RewriteRule ^book$ /php/book.php?id=1
答
Don't use alias, but mod_rewrite:
RewriteEngine On
RewriteRule ^book$ /php/book.php?id=1
Wrong regular expression ^book$
for /book
string. Should be ^/book$
.