微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

通过index.php重新路由所有php请求

如何通过index.PHP重新路由所有PHP页面请求?

我的.htaccess如下:

Options +FollowSymLinks
IndexIgnore */*
#Turn on the RewriteEngine
RewriteEngine On
#  Rules
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule !.*\.(js|ico|gif|jpg|png|css|pdf)$index.PHP%{REQUEST_URI} [L]

基本上,我试图模仿.NET主页. index.PHP具有站点页眉/页脚.

它将404重定向到index.PHP.如何使所有请求重定向PHP页面(index.PHP本身除外)?

这种方法有什么性能问题(不想使用框架)?

这是我使用的(并已使用年龄):
<IfModule mod_rewrite.c>
    # Redirect /index.PHP to / (optional,but recommended I guess)
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.PHP
    RewriteRule ^index.PHP/?(.*)$$1 [R=301,L]

    # Run everything else but real files through index.PHP
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$index.PHP/$1?%{QUERY_STRING} [L]
</IfModule>

正如评论所示,它将路由不是实际文件的每个请求到index.PHP

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐