【发布时间】:2016-05-24 01:02:35
【问题描述】:
有谁知道 apache 2.2 mod_rewrite 和 apache 2.4 rewrite 的区别!
我有一个 web builder 应用程序,它运行良好,但我想将代码从 apache 2.4 服务器迁移到 apache 2.2 服务器。
当我这样做时,我会在 2.2 服务器上的重写规则上得到一个递归循环:
这是在 apache 2.4 服务器上运行的 .htaccess 代码
# Powered by Domainsunder.ca
DirectoryIndex index.php index.cgi index.html
ErrorDocument 401 "Unauthorized"
ErrorDocument 403 "Forbidden"
RewriteEngine On
#### PERSISTENT CONTENT ####
#### PERSISTENT CONTENT END ####
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ sitepro/$1 [L,QSA]
#### PERSISTENT CONTENT ####
所以当我在 apache 2.2 上运行它时,它会无限循环并出错:
Thu Feb 11 17:04:03 2016] [error] [client x.x.x.x] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace., referer: http://www.domainsunder.ca/
所以我加了
RewriteCond %{ENV:REDIRECT_STATUS} 200
在 apache 2.2 .htaccess 上,但它仍然有错误的 URL,如 http://somedomain.ca/sitepro/mypage 而不是 http://somedomain.ca/mypage
现在屏幕上的错误信息是:
The requested URL /sitepro/domain_name_information/ was not found on this server.
文件 sitepro/index.php 应该呈现页面,它适用于 apache 2.4。
mod_rewrite 和 .htaccess 允许似乎工作,所以这似乎是一个 apache 引擎问题。
我需要添加什么来完成这项工作?
我在尝试让 Wordpress 在同一台 2.2 服务器上工作时也遇到了同样的问题。
我不想在这个 centOS 6.x 机器上运行 cpanel 或重新编译 apache。
【问题讨论】:
-
是的 - 我已将其编辑为更清晰的版本。
-
是的,.htaccess 在根目录中
-
这是完整的.htaccess
标签: wordpress .htaccess mod-rewrite apache2.4 apache2.2