简体   繁体   English

htAccess重定向所有.php除assets文件夹

[英]htAccess redirect all .php except assets folder

I want to redirect all .php scripts to index.php with htaccess. 我想用htaccess将所有.php脚本重定向到index.php。 Except the scripts that are inside the /assets/ folder. 除了/ assets /文件夹中的脚本。

For example: 例如:

   /test.php                         ->    /index.php
   /folder/test.php                  ->    /index.php
   /assets/test.php                  ->    /assets/test.php
   /assets/folder/folder/test.php    ->    /assets/folder/folder/test.php

This is my current htaccess file: 这是我目前的htaccess文件:

RewriteEngine on
RewriteCond %{REQUEST_URI} !(\.png|\.jpg|\.gif|\.jpeg|\.bmp|\.css|\.js|\.woff|\.woff2|\.map|\.ico|\.map)$
RewriteCond $1 !^(index\.php|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

Found the answer... 找到答案......

Add this to .htaccess: 将其添加到.htaccess:

RewriteCond %{REQUEST_URI} !^(/assets) RewriteCond%{REQUEST_URI}!^(/ assets)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM