.htaccess : Redirect all http requests to one file whitout 404 resp. code

只谈情不闲聊 提交于 2019-12-12 00:34:31

问题


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

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 ?


回答1:


You regex doesn't include / characters.

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


来源:https://stackoverflow.com/questions/13655618/htaccess-redirect-all-http-requests-to-one-file-whitout-404-resp-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!