URL重写似乎不起作用.阿帕奇2 [英] URL Rewriting doesn't seem to work. Apache2

查看:152
本文介绍了URL重写似乎不起作用.阿帕奇2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要这样,以便当用户转到 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]

它只是将我发送到带有404的/home目录.非常感谢您的帮助.谢谢.

It just sends me to the /home directory, with a nice 404. Help is appreciated. Thanks.

我已经尝试过重写一些我知道的工作,所以现在我确定这不是我的问题.我用phpinfo()检查过,是的,mod重写正在运行,我用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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆