加入收藏 | 设为首页 | 会员中心 | 我要投稿 安卓应用网 (https://www.0791zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > PHP > 正文

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

发布时间:2020-05-25 09:50:56 所属栏目:PHP 来源:互联网
导读:如何通过index.php重新路由所有php页面请求? 我的.htaccess如下: Options +FollowSymLinksIndexIgnore */*#Turn on the RewriteEngineRewriteEngine On# RulesRewriteCond %{REQUEST_FILENAME} !-fRewriteRule !.*.(js|ico|gif

如何通过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

(编辑:安卓应用网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读