我正在尝试执行以下操作:如果我去www.example.com/panel->我想在文件夹面板中打开index.php,如果我去www.example.com/panel/somehing-我希望它翻译这到www.example.com/panel/index.php?content=something
现在,我在这里尝试了所有可能的解决方案,其中包括重定向到子文件夹,例如
RewriteCond %{REQUEST_URI} !^/subfolder/public/ [NC]
RewriteRule ^(.*)$ subfolder/public/$1 [L]
但这完全覆盖了我的主要index.php并将所有内容重定向到子文件夹。
而且我确实使用简单的条件和规则,例如:
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/.+$
RewriteRule ^check-out/?$ index.php?content=check-out [NC,L]
这很不错,我想要的方式。
所以如果我在位置
www.example.com/panel/user
我需要类似的东西
RewriteRule ^panel/([^/]+)$ panel/index.php?content=$1 [NC,L]
凡([^ /] +)$和$ 1将在此情况下,代表“用户”和网站应该重定向到
www.example.com/panel/index.php?content=user
在您的内部panel/.htaccess
有以下代码:
DirectoryIndex index.php
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .+ index.php?content=$0 [L,QSA]
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句