这是我的文件结构
-- admin
|-- css
|-- style.css
|-- payments
|-- index.php
|-- ajax.php
|-- index.php
-- public
|-- css
|-- style.css
|-- payments
|-- index.php
|-- test.php
|-- index.php
|-- test.php
-- .htaccess
-- index.php
如果有人访问该目录,我不希望/index.php文件做任何事情。相反,一切都将由.htaccess控制。
这就是我对.htaccess所拥有的,我必须说的非常混乱。
# Redirect Home
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^$ public/index.php [QSA,L,NC]
# Public Sub-Directories Sub-Directory Pages
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !public/(.*)
RewriteCond %{REQUEST_URI} !css(.*)
RewriteCond %{REQUEST_URI} !js(.*)
RewriteRule ^(.*)/(.*)$ public/$1/$2.php [QSA,L,NC]
# Public Sub-Directories
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !public/(.*)
RewriteCond %{REQUEST_URI} !css(.*)
RewriteCond %{REQUEST_URI} !js(.*)
RewriteRule ^(.*)$ public/$1/index.php [QSA,L,NC]
# Public Pages
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !css(.*)
RewriteCond %{REQUEST_URI} !js(.*)
RewriteCond %{REQUEST_URI} !public/(.*)
RewriteRule ^(.*)$ public/$1.php [QSA,L,NC]
# Public Directory Redirects
RewriteRule ^css/(.*)($|/$) public/css/$1 [QSA,L]
RewriteRule ^js/(.*)($|/$) public/css/$1 [QSA,L]
# Admin Redirect
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^admin/modules/([^/\.]+)/([^/\.]+)($|/$) admin/index.php?admin=1&module=$1&p=$2 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^admin/modules/([^/\.]+)($|/$) admin/index.php?admin=1&module=$1 [QSA,L]
RewriteRule ^admin/modules($|/$) admin/index.php?admin=1 [QSA,L]
基本上我正在尝试实现以下重定向:
用户无法看到真实的网址
最终会有更多,但甚至还没有基础知识:(