简体   繁体   中英

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. 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).

Now I had to update the server and apache 2.4.9 now gives me this error:

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]
  • Tried ^/news([0-9]+)$ /news.php?%{QUERY_STRING} [L,NC,QSA]
  • Tried ^/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

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 !

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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