的.htaccess:重定向所有的HTTP请求到一个文件whitout 404 RESP。 code [英] .htaccess : Redirect all http requests to one file whitout 404 resp. code

查看:50
本文介绍了的.htaccess:重定向所有的HTTP请求到一个文件whitout 404 RESP。 code的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想所有的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

这篇关于的.htaccess:重定向所有的HTTP请求到一个文件whitout 404 RESP。 code的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆