URL 重写似乎不起作用.阿帕奇2 [英] URL Rewriting doesn't seem to work. Apache2
问题描述
我希望这样当用户去http://mysite.com/home
它将他重定向到 http://mysite.com/page.php?id=home
.这是我放在 .htaccess 中的内容,但它似乎不起作用.
I would like it so that when the user goes to
http://mysite.com/home
that it redirects him to http://mysite.com/page.php?id=home
. This is what I put in my .htaccess, but it doesn't seem to work.
RewriteEngine On
RewriteRule ^/(.+)$ page.php?id=$1 [NC,L]
它只是将我发送到/home 目录,并显示一个不错的 404.感谢您的帮助.谢谢.
It just sends me to the /home directory, with a nice 404. Help is appreciated. Thanks.
我已经尝试了一些我知道的重写,所以现在我确定这不是我的问题.我检查了 phpinfo()
,是的,正在运行 mod rewrite,我使用 LAMP 设置了 apache2,我正在运行最新版本的 Linux Mint.
I've tried some rewrite I know work, so now I'm certain it's not that my problem. I checked with phpinfo()
and yes, mod rewrite is running, I set up apache2 with LAMP, I'm running the latest version of Linux Mint.
推荐答案
好的,我解决了这个问题,我就是这样做的.
Ok well I fixed the problem, this is how I did it.
sudo gedit/etc/apache2/sites-available/default
然后我在文件的 /var/www/
部分将 AllowOverride None
修改为 AllowOverride all
and then I modified AllowOverride None
to AllowOverride all
in the /var/www/
part of the file
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride all #This was 'None' before, change it to 'all'
Order allow,deny
allow from all
</Directory>
这篇关于URL 重写似乎不起作用.阿帕奇2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!