不能得到的.htaccess mod_rewrite规则的工作 - 404未找​​到 [英] Can't get .htaccess mod_rewrite rules to work - 404 Not Found

查看:215
本文介绍了不能得到的.htaccess mod_rewrite规则的工作 - 404未找​​到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让一个简单的.htaccess重写规则的工作,但我似乎无法工作了。

I'm trying to get a simple .htaccess rewrite rule to work, but I can't seem to work it out.

我的.htaccess是这样的:

My .htaccess looks like:

RewriteEngine On
RewriteRule ^api$ phpinfo.php
ErrorDocument 404 /error.php

php_flag  display_errors                  on
php_flag  display_startup_errors          on
php_flag  file_uploads                    on
php_value error_reporting                 2047
php_value max_input_time                  60
php_value post_max_size                   8M
php_value upload_max_filesize             2M

当我访问 / API ,我得到一个404错误,指出 / API 无法找到。

When I access /api, I get a 404 error saying that /api can't be found.

我的Apache的conf文件看起来像:

My apache conf file looks like:

<IfModule mod_ssl.c>
  NameVirtualHost 10.104.17.3:443
  <VirtualHost 10.104.17.3:443>
    ServerName orddev.foo.com.au
    DocumentRoot /var/www/orddev.foo.com.au___443/html
    <Directory />
      Options FollowSymLinks
      AllowOverride All
    </Directory>
    <Directory "/var/www/orddev.foo.com.au___443/html">
      Options FollowSymLinks MultiViews IncludesNOEXEC
      AllowOverride All
      Order allow,deny
      Allow from all
    </Directory>
    <IfModule mod_php5.c>
      php_admin_value upload_tmp_dir "/var/www/orders.foo.com.au___443/resources/_tmp/upload/"
    </IfModule>
    <IfModule mod_rewrite.c>
      RewriteEngine on
      RewriteCond %{REQUEST_METHOD} ^TRACE
      RewriteRule .* - [F]
    </IfModule>
    ErrorLog  logs/orddev.foo.com.au___443/ssl_error.log
    CustomLog logs/orddev.foo.com.au___443/ssl_access.log combinedio
    CustomLog logs/orddev.foo.com.au___443/ssl_request.log ssl
    LogLevel warn
    SSLEngine on
    SSLProtocol all -SSLv2
    SSLCipherSuite HIGH:MEDIUM:!aNULL:+SHA1:+MD5:!SSLv2
    SSLCertificateFile /etc/pki/tls/certs/orddev.foo.com.au.crt
    SSLCertificateKeyFile /etc/pki/tls/private/orddev.foo.com.au.key
    <Files ~ "\.(cgi|shtml|phtml|php|php3?)$">
      SSLOptions +StdEnvVars
    </Files>
    SetEnvIf User-Agent ".*MSIE.*" \
      nokeepalive ssl-unclean-shutdown \
      downgrade-1.0 force-response-1.0
  </VirtualHost>
</IfModule>

知不知道我做错了吗? 我知道的.htaccess被理解为如果我改变了404号文件,我得到一个错误约404文件没有被正确安装。

Any idea what I'm doing wrong? I know the .htaccess is being read as if I change the 404 document, I get an error about the 404 document not being setup properly.

推荐答案

这听起来像你的Apache没有加载mod_rewrite的。

It sounds like your apache isn't loading mod_rewrite.

找到你的httpd.conf并搜索rewrite_module。

Locate your httpd.conf and search for "rewrite_module".

如果该行以#(使它评论)开始,去掉#并重新启动Apache。

If that line begins with a # (making it a comment), remove the # and restart apache.

在我的,行是:

LoadModule rewrite_module libexec/apache2/mod_rewrite.so

......但情况因人而异。

...but YMMV.

这篇关于不能得到的.htaccess mod_rewrite规则的工作 - 404未找​​到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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