我在cPanel
中具有以下目录结构。
public_html/
-folder1/
-folder2/
-example/
-administrator/
-examplefolder2/
-index.html
-.htaccess [inner_htaccess]
-.htaccess [main_htaccess]
我的域是:example.com
。
# This file has all the contents that are specific to the source code of example. It is based on Joomla and has been working perfectly ever since until I changed server and new structure came into the picture. Now, my shared hosting has primary domain set to example.com.
IndexIgnore *
Options +FollowSymlinks
Options -Indexes
RewriteEngine On
RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
RewriteRule .* index.php [F]
RewriteCond %{HTTP_HOST} !^www.example.com [NC]
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]
RewriteBase /
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_URI} !^/index\.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L]
# This htaccess is at the root of public_html where example.com is pointed to by default. Using [this guide][1], I pasted following code.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteCond %{REQUEST_URI} !^/example/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /example/$1
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteRule ^(/)?$ example/index.html [L]
example.com
应该从/example
服务器服务器文件/example
不应出现在网址中。index.html
不应出现在url中。 (以前从来没有来过)example.com
应该始终以www
打开https
。folder1
和folder2
。对public_html
的所有请求都应该简单地传递到example/
文件夹中,然后检查inner_htaccess
规则。 Non www
网址将index.html
附加到网址。喜欢:
https://www.example.com/ -> https://www.example.com/ # Okay
http://www.example.com/example/ -> https://www.example.com/ # Okay
http://example.com/ -> https://www.example.com/index.html # Not Okay - Added index.html
https://example.com/ -> https://www.example.com/index.html # Not Okay - Added index.html
任何以www
开头的网址都不会从网址中删除example
子文件夹。喜欢:
https://www.example.com/example/ -> https://www.example.com/example/ # Not Okay - No removal of subdir in url
http://www.example.com/example/ -> https://www.example.com/example/ # Not Okay - No removal of subdir in url
http://example.com/example/ -> https://www.example.com/ # Okay - Sub Dir removed
https://example.com/example/ -> https://www.example.com/ # Okay - Sub Dir removed
folder1
和folder2
可以访问。