的.htaccess:重定向所有的HTTP请求到一个文件whitout 404 RESP。 code有的、重定向、文件、HTTP

由网友(烂人一枚i)分享简介:我想所有的HTTP请求重定向到一个文件 Controller.php这样 I want to redirect all http request to one file controller.php# My .htaccessRewriteCond %{REQUEST_URI} !\.(.+)$Rewrite...

我想所有的HTTP请求重定向到一个文件 Controller.php这样

I want to redirect all http request to one file controller.php

# My .htaccess
RewriteCond %{REQUEST_URI}  !.(.+)$
RewriteRule ^(.*)([^/])$ http://%{HTTP_HOST}/$1$2/ [L,R=301]
RewriteRule ^([a-zA-Z0-9_-]+)$      controller.php

考虑这一请求 http://mysite.com/en-US/messages/new/ 我有PHP脚本来获取所有的URL参数,并把它们 Controller.php这样是被显示,但404响应code由阿帕奇送出过。 我怎样才能成为一个好重写规则,以prevent 404回应?

Consider this request http://mysite.com/en-US/messages/new/ I have php script to get all url parameters and treat them controller.php is been displayed but a 404 response code is sent too by Apache. How can I make a good rewrite rule to prevent 404 response ?

推荐答案

您的正则表达式不包括 / 字符。

You regex doesn't include / characters.

RewriteRule ^([a-zA-Z0-9_-/]+)$      controller.php
阅读全文

相关推荐

最新文章