我完全被 htaccess 重写无法在我的服务器上运行。这是 Codeigniter 的基本 index.php 重写,在我的 Mac 上开发时工作正常,但在我的服务器上失败(CentOS、Apache 2、WHM)
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
尝试加载 /about/ 将显示 index.php 页面。/index.php/about 将显示正确的页面。我已经尝试了所有我能想到的选项组合,但都无济于事。我的 rewrite.log 示例如下。
[dev.tirius.co.uk/sid#5d65288][rid#5e37c00/initial] (3) [per-dir /home/tirius/subdomains/dev/public_html/] add path info postfix: /home/tirius/subdomains/dev/public_html/about -> /home/tirius/subdomains/dev/public_html/about/
[dev.tirius.co.uk/sid#5d65288][rid#5e37c00/initial] (3) [per-dir /home/tirius/subdomains/dev/public_html/] strip per-dir prefix: /home/tirius/subdomains/dev/public_html/about/ -> about/
[dev.tirius.co.uk/sid#5d65288][rid#5e37c00/initial] (3) [per-dir /home/tirius/subdomains/dev/public_html/] applying pattern '^(.*)$' to uri 'about/'
[dev.tirius.co.uk/sid#5d65288][rid#5e37c00/initial] (2) [per-dir /home/tirius/subdomains/dev/public_html/] rewrite about/ -> /index.php/about/
[dev.tirius.co.uk/sid#5d65288][rid#5e37c00/initial] (1) [per-dir /home/tirius/subdomains/dev/public_html/] internal redirect with /index.php/about/ [INTERNAL REDIRECT]
[dev.tirius.co.uk/sid#5d65288][rid#5e3f7c8/initial/redir#1] (3) [per-dir /home/tirius/subdomains/dev/public_html/] add path info postfix: /home/tirius/subdomains/dev/public_html/index.php -> /home/tirius/subdomains/dev/public_html/index.php/about/
[dev.tirius.co.uk/sid#5d65288][rid#5e3f7c8/initial/redir#1] (3) [per-dir /home/tirius/subdomains/dev/public_html/] strip per-dir prefix: /home/tirius/subdomains/dev/public_html/index.php/about/ -> index.php/about/
[dev.tirius.co.uk/sid#5d65288][rid#5e3f7c8/initial/redir#1] (3) [per-dir /home/tirius/subdomains/dev/public_html/] applying pattern '^(.*)$' to uri 'index.php/about/'
[dev.tirius.co.uk/sid#5d65288][rid#5e3f7c8/initial/redir#1] (1) [per-dir /home/tirius/subdomains/dev/public_html/] pass through /home/tirius/subdomains/dev/public_html/index.php
如您所见,htaccess 已被拾取并且 mod_rewrite 已启用并正在工作,但似乎没有任何内容被附加到 index.php
这一定是一个 Apache 配置问题,但我真的不知道它可能是什么。
来自 httpd.conf 的示例
<Directory "/">
Options ExecCGI FollowSymLinks IncludesNOEXEC Indexes MultiViews SymLinksIfOwnerMatch
AllowOverride All
</Directory>