多应用模式下,忽略项目的入口文件,重写Apache规则

多应用模式下,忽略项目的入口文件,重写Apache规则

首先,我的项目是具有两个应用,admin和index,同时给它们绑定了域名,但是每次访问时都需要加入项目的入口文件地址 index.php ,为了忽略这个入口文件,只能通过重写Apache的规则。

找到项目根目录下的 Public.htaccess ,对其进行编辑即可。

text 复制代码
<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>

    RewriteEngine On

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

    # Handle Front Controller....
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

测试访问,此时访问控制器下的对应方法已经不再需要index.php入口文件了。

相关推荐
℡終嚸♂6801 天前
Apache Tomcat CVE-2025-55752 CTF Writeup
tomcat·apache·firefox
27669582921 天前
某白山小程序限制PC端调试
python·小程序·apache·小程序逆向·某白山·限制pc调试
SuperherRo1 天前
服务攻防-开发框架安全&ThinkPHP&Laravel&SpringBoot&Struts2&SpringCloud&复现
spring boot·laravel·thinkphp·struts2·框架安全
杰建云1671 天前
商家小程序怎么做?
大数据·apache·小程序制作
小冷爱学习!2 天前
Apache Shiro 1.2.4 反序列化漏洞Shiro-550(CVE-2016-4437)
服务器·网络·python·安全·网络安全·apache
有趣灵魂2 天前
Java Spring Boot根据Word模板和动态数据生成Word文件
java·spring boot·word·apache
phltxy2 天前
分布式链路追踪实战:Apache SkyWalking 从入门到精通
分布式·apache·skywalking
quweiie3 天前
thinkphp8生成海报
thinkphp·海报
大厂数码评测员3 天前
免费菜谱管理小程序怎么做才顺手:从情侣、个人、家庭三类场景拆需求和实现
服务器·小程序·apache