如何激活mod_rewrite的? [英] How to activate mod_rewrite?

查看:133
本文介绍了如何激活mod_rewrite的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这个问题已经被问了几次。但我不能得到它的工作。

I know that this question have been asked several times. But I can't get it to work.

我在Ubuntu的服务器上安装的Apache2我还可以确认所安装的mod_rewrite使用的phpinfo();我也把我的根文件夹(/var/www/.htaccess)呼吁.htaccess文件。在我的.htaccess文件我粘贴以下code:

I installed Apache2 in my Ubuntu server I can also confirm that mod_rewrite is installed using phpinfo();. I have also put a file called .htaccess in my root folder(/var/www/.htaccess). In my .htaccess file I paste the following code:

Options +FollowSymLinks 
RewriteEngine On 
RewriteRule ^.*$ test.php

所以一切都将被重定向到test.php的

So everything is redirected to test.php

但它仍然无法正常工作。所以,我检查在/ etc /我的Apache2 httpd.conf文件。这完全是空的,没有code线(这似乎有点奇怪我)?然而,在#2检查答案应该有至少以下$ C $在httpd.conf C:

But it still doesn't work. So I checked my httpd.conf file under /etc/apache2. It is completely empty, with no lines of code (This seems a little odd to me)?! However checking in Stackoverflow answers there should be at least the following code in httpd.conf:

<Directory />
    Options FollowSymLinks
    AllowOverride All
    Order deny,allow
    Deny from all
    Satisfy all
</Directory>

所以我粘贴在httpd.conf code。并重新启动Apache加上须藤/etc/init.d/apache重启。它仍然不起作用?

我还测试打开文件/ / 000-default和/站点可用/默认情况下,启用站点,其中所有的虚拟主机设置的谎言和改变目录 /无功/网络 / 来的AllowOverride全部。 mod_rewrite的仍然无法正常工作。任何人都可以请帮助我。此问题已被烤我的坚果一段时间。

I have also tested to open the file /sites-enabled/000-default and /sites-available/default, where all virtual host settings lies and change under the directory /var/www and / to AllowOverride All. The mod_rewrite still doesn't work. Can anyone please help me. This problem has been baking my nuts for a while.

另外,我的apache2.conf文件不起作用。我试着写索姆废话。而且它仍然给了我正常的结果,而不是HTTP 500错误

Also, my apache2.conf file doesn't work. I tried to write som nonsense. And it is still gives me the normal result instead of http 500 error

推荐答案

所有的尼尔斯·汜的建议是最聪明的人(我认为)。不过,我想补充一点作为第一个建议:尝试推出并通过Ubuntu的命令停止Apache:那么当它应该被停止,的确保的它停即验证您的本地网页已经不显示

All suggestions from Niels Bom are the smartest ones (I think). But I would add this as the first suggestion: try to launch and stop apache via the Ubuntu command: then when it's supposed to be stopped, make sure it's stopped ie verify your local page doesn't show anymore.


  • 阅读什么是在文件夹的/ etc / apache2的/ 。应该有 apache2.conf conf.d envvars中的httpd.conf MODS的可用启用MODS-ports.conf网站可用启用的站点 -

  • 那么,如果一切正常,看看启用MODS-其中,如果MODS的启用,如果是这样,那么你可以去,你会发现,否则取看看其他的答案有关启用modrewrite

  • 看看启用的站点 - :这是在那里你可以找到那些网站......(猜猜是什么?)运行。应该有默认网​​站

  • 如果是这样,打开此文件,并尝试把阿帕奇废话它,重新启动服务器,看它是否幸福。如果不是高兴,是很好的。如果它是快乐的,那么你正在处理的错误的文件

  • 最后:尝试检查什么是htaccess的文件作为这个默认的虚拟主机授权。下面是他们的工作方式:如果Apache没有找到在虚拟主机文件中的任何指令,它将应用全局配置。所以我建议加在你的虚拟主机文件中的配置,在℃之间的虚拟主机&GT; - &LT; /虚拟主机&GT; 标签(当然)。

  • read what's in the folder /etc/apache2/. There should be apache2.conf conf.d envvars httpd.conf mods-available mods-enabled ports.conf sites-available sites-enabled
  • then if everything is ok, take a look at mods-enabled where you will find if the mods are enabled if so, then you can go on, otherwise take a look at the other answers about enabling modrewrite
  • take a look at sites-enabled: it's where you can find the sites that are... (guess what?) enabled. There should be the default website.
  • if so, open this file, and try to put apache nonsense in it, restart the server and see if it's happy or not. If it's not happy that's good. If it's happy then you're working on the wrong file
  • last: try to check what are the authorisations for htaccess files for this default vhost. Here's the way they work: if Apache doesn't find any directive in the vhost file, it will apply the global configuration. So I'd suggest to add the configuration in your vhost file, between the <virtualhost> - </virtualhost> tags (of course).

请告诉我这是怎么回事,我会很高兴相应地更新我的问题。

Please tell me what's going on and I'd be glad to update my question accordingly.

这篇关于如何激活mod_rewrite的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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