简体   繁体   English

Mod从Apache 2.2重写Apache 2.4.9

[英]Mod rewrite apache 2.4.9 from apache 2.2

Ok, so I had a rule in the .htaccess of the site I am building that worked. 好的,所以我在正在构建的网站的.htaccess中有一条规则。 Here it is: 这里是:

RewriteRule ^/news/([0-9]+)$ /news.php?%{QUERY_STRING} [L,NC,QSA]

It transformed mysite.com/test/ to mysite.com/test.php (well, not to the end user but this is what it was doing in the background). 它将mysite.com/test/转换为mysite.com/test.php(好吧,不是最终用户,但这是它在后台执行的操作)。

Now I had to update the server and apache 2.4.9 now gives me this error: 现在我不得不更新服务器,而Apache 2.4.9现在给我这个错误:

The requested URL /news.php/ was not found on this server.

Starting to bang my head on the wall here. 开始在这里撞墙。

What I already did: 我已经做了:

  • Tried ^news/([0-9]+)$ /news.php?%{QUERY_STRING} [L,NC,QSA] 尝试过^ news /([0-9] +)$ /news.php?%{QUERY_STRING} [L,NC,QSA]
  • Tried ^/news([0-9]+)$ /news.php?%{QUERY_STRING} [L,NC,QSA] 尝试过^ / news([0-9] +)$ /news.php?%{QUERY_STRING} [L,NC,QSA]
  • Tried ^/news/([0-9]+)$ /news.php [L,NC,QSA] 尝试过^ / news /([[0-9] +)$ /news.php [L,NC,QSA]

I know I must have done something wrong in there but it was working fine before xx 我知道我在那里一定做错了什么,但是在xx之前一切正常

Some how this is now working: 现在这是如何工作的:

RewriteRule ^news(.*) /news.php?%{QUERY_STRING} [L,NC,QSA]

I will have to re-code some logic in the php to check the querystring I think, but at least now it does find the files ! 我将不得不在php中重新编码一些逻辑以检查我认为的querystring,但至少现在它确实找到了文件!

尝试将.htaccess的名称更改为不带点号或“ htaccess.txt”的类似“ htaccess”的名称,并使用AccessFileNAme [httpd.apache.org]指令告诉apache改用该新文件名。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM