首页 文章

htaccess没有重定向到主index.php

提问于
浏览
0

htaccess不会将我输入的内容重定向到我服务器上的 index.php . 但它在我的本地服务器(wamp)上运行良好 .

这是htaccess:

<IfModule mod_rewrite.c>
    Options -MultiViews

    RewriteEngine on
    RewriteBase /

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^ index.php [L]
</IfModule>

这是最基本的htaccess ....

如果我去主网址没有问题,页面加载,但如果我输入类似 /inventaris/index 的东西,它给我一个404页面 .

在同一台服务器上,我有其他网站使用htaccess . 其中一个是带有永久链接的wordpress博客,因此启用了mod_rewrite .

任何人都知道为什么这不起作用?我的实时服务器在Ubuntu上运行 .

Update: Loaded Modules
core mod_log_config mod_logio prefork http_core mod_so mod_alias mod_auth_basic mod_authn_file mod_authz_default mod_authz_groupfile mod_authz_host mod_authz_user mod_autoindex mod_cgi mod_deflate mod_dir mod_env mod_mime mod_negotiation mod_php5 mod_reqtimeout mod_rewrite mod_setenvif mod_status

3 回答

  • 0

    确保FollowSymLinks设置在Options下,我会使用

    RewriteRule ^index\.php$ - [L]
    RewriteRule ^ /index.php [L]
    
  • 0

    这也有助于你获得 PATH_INFO .

    DirectoryIndex index.php
    
    IndexIgnore */*
    RewriteEngine On
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule (.*) index.php/$1 [QSA,L]
    
  • 1

    经过一些调试后,我发现 .htaccess 文件没有做任何事情 . 甚至不是一个基本的前锋 .

    在一些谷歌搜索后,我将虚拟主机设置 AllowOverride None 更新为 AllowOverride All . 默认虚拟主机也是一样(只是为了确定) . 它似乎现在有效 .

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

    解释我发现: You need to modify the line containing AllowOverride None to read AllowOverride All. This tells Apache that it's okay to allow .htaccess files to over-ride previous directives.

相关问题