我有一个非常简单的 RewriteRule,但我不知道为什么它不想工作。也许它只是疲惫的谈话,但有些事情似乎很奇怪。

我想将一个看起来像 http://mydomain.com/abc 的 URL 重定向到 http://mydomain.com/abc/index.php/xyz ,但我不想更改 URL。

这是我的 .htaccess 全文:

RewriteEngine On
RewriteBase /abc/

#redirect the homepage
RewriteRule ^$  index.php/msj [QSA,L]

当我这样做时,我得到“没有指定输入文件。”。如果我将 [QSA,L] 更改为 [R] 它可以工作,但它实际上会重定向 URL。

我有什么误解?

编辑:$_SERVER 的输出
array(34) { [
"PATH"]=> string(29) "/bin:/usr/bin:/sbin:/usr/sbin" [
"RAILS_ENV"]=> string(10) "production" [
"FCGI_ROLE"]=> string(9) "RESPONDER" [
"UNIQUE_ID"]=> string(24) "UxDcvK3suH0AABgWvXUAAAAj" [
"SCRIPT_URL"]=> string(1) "/" [
"SCRIPT_URI"]=> string(22) "http://themspress.org/" [
"dsid"]=> string(8) "25793844" [
"ds_id_25793844"]=> string(0) "" [
"DH_USER"]=> string(13) "juancommander" [
"HTTP_HOST"]=> string(14) "themspress.org" [
"HTTP_CONNECTION"]=> string(5) "close" [
"HTTP_ACCEPT"]=> string(74) "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8" [
"HTTP_USER_AGENT"]=> string(120) "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.117 Safari/537.36" [
"HTTP_ACCEPT_ENCODING"]=> string(17) "gzip,deflate,sdch" [
"HTTP_ACCEPT_LANGUAGE"]=> string(23) "en-US,en;q=0.8,es;q=0.6" [
"HTTP_COOKIE"]=> string(190) "OJSSID=Siy7xdofJurGtBcNUk1880; __utma=154159997.1153519437.1393351515.1393522373.1393598726.4; __utmc=154159997; __utmz=154159997.1393351515.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)" [
"SERVER_SIGNATURE"]=> string(0) "" [
"SERVER_SOFTWARE"]=> string(6) "Apache" [
"SERVER_NAME"]=> string(14) "themspress.org" [
"SERVER_ADDR"]=> string(15) "173.236.187.201" [
"SERVER_PORT"]=> string(2) "80" [
"REMOTE_ADDR"]=> string(14) "189.138.120.63" [
"DOCUMENT_ROOT"]=> string(51) "/home/juancommander/themspress.org/var/www/html/ojs" [
"SERVER_ADMIN"]=> string(24) "[email protected]" [
"SCRIPT_FILENAME"]=> string(61) "/home/juancommander/themspress.org/var/www/html/ojs/index.php" [
"REMOTE_PORT"]=> string(5) "53719" [
"GATEWAY_INTERFACE"]=> string(7) "CGI/1.1" [
"SERVER_PROTOCOL"]=> string(8) "HTTP/1.1" [
"REQUEST_METHOD"]=> string(3) "GET" [
"QUERY_STRING"]=> string(0) "" [
"REQUEST_URI"]=> string(1) "/" [
"SCRIPT_NAME"]=> string(10) "/index.php" [
"PHP_SELF"]=> string(10) "/index.php" [
"REQUEST_TIME"]=> int(1393614012) }

最佳答案

我在 Dreamhost documentation 中找到了问题的根源。

看起来:



我使用的 CMS 不喜欢那样。所以撤消使用 ?$1 的评论是在正确的轨道上,但是因为我没有解释,而且我使用的 CMS(开放日志系统)在 ? 之后不能与路径信息一起工作,那么它就无法正常工作。

解决方案是从 FastCGI 更改为普通 CGI。

关于apache - 为什么这个重写规则适用于 [R] 而不适用于 [QSA,L]?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/21747063/

10-13 04:32