如何在htaccess中从子文件夹而不是根文件夹加载文件


How to load files from a subfolder instead of root folder in htaccess?

我的测试网站是frontshoppe.com

并且我有下面的CCD_ 1。

RewriteEngine打开重写代码%{HTTP_HOST}^frontshoppe''.com$重写规则(.*)http://www.frontshoppe.com/1美元[R=301,L]重写规则^$admin[L]

是的,它加载得很好,就像我希望它加载管理文件夹的内容一样。。但我也希望网址是..

仅限www.frontshoppe.com
而不是
www.frontshoppe.com/admin

这应该有效:

RewriteEngine on
# Change yourdomain.com to be your primary domain.
RewriteCond %{HTTP_HOST} ^(www.)?frontshoppe.com$
# Change 'subfolder' to be the folder you will use for your primary domain.
RewriteCond %{REQUEST_URI} !^/admin/
# Don't change this line.
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d
# Change 'subfolder' to be the folder you will use for your primary domain.
RewriteRule ^(.*)$ /admin/$1
# Change yourdomain.com to be your primary domain again. 
# Change 'subfolder' to be the folder you will use for your primary domain 
# followed by / then the main file for your site, index.php, index.html, etc.
RewriteCond %{HTTP_HOST} ^(www.)?frontshoppe.com$ 
RewriteRule ^(/)?$ admin/index.php [L]

您可以有这样的规则:

RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^frontshoppe'.com$
RewriteRule (.*) http://www.%{HTTP_HOST}/$1 [R=301,L,NE]
RewriteCond %{THE_REQUEST} 's/+admin/('S*) [NC]
RewriteRule ^ /%1 [L,R=302,NE]
RewriteRule ^((?!admin/).*)$ admin/$1 [L,NC]