Php 如何防止在输入url时重定向到子域?

Php 如何防止在输入url时重定向到子域?,php,apache,.htaccess,mod-rewrite,Php,Apache,.htaccess,Mod Rewrite,这很难解释,但我正在为我正在制作的路由器/框架重写URL。我将我的根目录指向一个名为public的文件夹,并在该文件夹中处理index.php等的重写。但我希望能够访问css和js文件夹。无论如何,每当我转到/css时,它都会将我带到/public/css,并允许我查看文件和列表目录,但当我查看文件时,它允许我查看文件而不更改URL。所以基本上,如果有人转到/css,我希望它保持这样,而不是改成/public/css root.htaccess文件 RewriteEngine On Rewrit

这很难解释,但我正在为我正在制作的路由器/框架重写URL。我将我的根目录指向一个名为public的文件夹,并在该文件夹中处理index.php等的重写。但我希望能够访问css和js文件夹。无论如何,每当我转到/css时,它都会将我带到/public/css,并允许我查看文件和列表目录,但当我查看文件时,它允许我查看文件而不更改URL。所以基本上,如果有人转到/css,我希望它保持这样,而不是改成/public/css

root.htaccess文件

RewriteEngine On
RewriteBase /
RewriteRule ^$ /public/ [L]
RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(.*)$ /public/$1
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
    Options -MultiViews
</IfModule>

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
public.htaccess文件

RewriteEngine On
RewriteBase /
RewriteRule ^$ /public/ [L]
RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(.*)$ /public/$1
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
    Options -MultiViews
</IfModule>

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

选项-多视图
重新启动发动机
重写cond%{REQUEST_FILENAME}-d
重写cond%{REQUEST_FILENAME}-f
重写规则^index.php[L]

更改您的根目录。htaccess to this:

RewriteEngine On
RewriteBase /

RewriteRule ^$ public/ [L]
RewriteCond %{REQUEST_URI} !^/(public|css|js)/ [NC]
RewriteRule ^(.*)$ public/$1 [L]
现在,此重写规则不会影响
/css/
/js/
文件夹