URL重写不工作.htaccess文件 [英] apache mod_rewrite not working with .htaccess file

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

问题描述

OK,我一直有与AWS什么的,有些问题,例如,我似乎无法得到mod_rewrite的工作。

OK, I've been having some issues with aws or something, such that I cannot seem to get mod_rewrite to work.

只是为了测试,我做了以下内容:

Just for testing purposes I've done the following:

1使用AWS控制台部署从向导新鲜AMI 64位实例

1 used aws console to deploy fresh ami 64 bit instance from wizard

2百胜安装的Apache

2 yum installed apache

3编辑/etc/httpd/conf/httpd.conf中: 这样

3 edited /etc/httpd/conf/httpd.conf: so that

<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>

看起来

<Directory />
    Options FollowSymLinks
    AllowOverride All
</Directory>

4确信

LoadModule rewrite_module modules/mod_rewrite.so

是文件,并取消注释研究。

is in the file and uncommented.

5重启apache的:

5 restarted apache:

 sudo /sbin/service httpd restart

6,创建两个新文件:

6 created two new files:

/var/www/html/test1.html

包括:

this is test1!

/var/www/html/test2.html

包括:

this is test2!

7创建的文件:

7 created file:

/var/www/html/.htaccess

包含(共):

contains (IN TOTAL):

RewriteEngine on
RewriteRule ^test1\.html$ test2.html [L]

8到:

http://[my aws server]/test1.html

我得到这是test1的!

Am getting "this is test1!"

我在这里做得不对,但对我的生活中,我不知道。任何帮助是极大的AP preciated ...

I am doing something wrong here, but for the life of me I have no idea what. Any help is greatly appreciated...

编辑:我添加废话字符/数字我的.htaccess文件的开头,并重新启动Apache的(不是100%肯定是需要的,但什么哎...),什么都没有发生。换句话说,我预计要到URL [AWS服务器] /test1.html会导致一些错误,但事实并非如此。我怀疑Apache不连读取.htaccess文件。

I added nonsense chars/numbers to the beginning of my .htaccess file, and restarted apache (not 100% sure that is needed, but what the hey...), and nothing happened. In other words, I expected that going to the url [aws server]/test1.html would result in some kind of error, but it did not. I suspect apache is not even reading the .htaccess file.

编辑:我添加以下到我的httpd.conf文件:

I added the following to my httpd.conf file:

RewriteLog "/tmp/rewrite.log"
RewriteLogLevel 9

当我重新启动Apache的文件被创建,但从来都没有去那里的时候,我去任一页我已经成立了。我没有做一些事情非常,非常基本的在这里,但我不知道是什么......

The file is created when I restart apache, but nothing ever goes in there when I go to either page I've set up. I'm failing to do something very, very basic here, but I'm not sure what...

推荐答案

不知道这是你的问题的原因,但你不应该乱用

Not sure if this is the cause of your problems, but you shouldn't mess with the

<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>

行,它应该是这样的:

line, and it should be something like:

<Directory />
    Options FollowSymLinks
    AllowOverride None
    Deny from all
</Directory>

您应该添加您的文档根目录为不同的容器

<Directory /var/www/html/>
    Options FollowSymLinks
    AllowOverride All
    Allow from all
</Directory>

这篇关于URL重写不工作.htaccess文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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