[英]subdomain wildcard .htaccess for escape cloudflare
I have example.com
domain and set on cloudflare. 我有example.com
域,并设置为cloudflare。 But some time I don't need to use cloudflare, so I create up.example.com
subdomain and unused of cloudflare for it. 但是有一段时间我不需要使用cloudflare,因此我创建了up.example.com
子域,并且没有使用它的cloudflare。 then I park it on main domain. 然后我将其停放在主域名上。 That means the example.com
and up.example.com
point to root site. 这意味着example.com
和up.example.com
指向根站点。 Now for cover duplicate content in SEO, I need to a .htaccess
file. 现在,对于SEO中重复的内容,我需要一个.htaccess
文件。
These items is important for me: 这些项目对我很重要:
upload
controller must be accessible from subdomain. 带有upload
控制器的所有地址都必须可以从子域访问。 for example: up.example.com/upload/ 例如:up.example.com/upload/ For this, I write a code here: 为此,我在这里编写代码:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^up\..+ [NC]
RewriteCond %{REQUEST_URI} !^(/upload/?[a-z,A-Z,0-9]*)$ [NC]
RewriteRule . - [R=404,L,NS]
# Hide index.php , this used for YII PHP Framework
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L,QSA]
But in this code my problem is: 但是在这段代码中,我的问题是:
Not Found. The requested URL /index.php was not found on this server.
up.example.com/upload/test =>让我Not Found. The requested URL /index.php was not found on this server.
Not Found. The requested URL /index.php was not found on this server.
, but must open it. ,但必须将其打开。 Note: about another URLs I get correct 404 error, for example for up.example.com/upload/test.jpg I get Not Found. The requested URL /upload/test.jpg was not found on this server.
注意:关于另一个URL,我得到正确的404错误,例如,对于up.example.com/upload/test.jpg,我Not Found. The requested URL /upload/test.jpg was not found on this server.
Not Found. The requested URL /upload/test.jpg was not found on this server.
error message, in this error message pointed exactly to /upload/test.jpg
but about up.example.com/upload/test
in error message pointed to index.php
file! 错误消息,在此错误消息中完全指向/upload/test.jpg
但在错误消息中指向up.example.com/upload/test
指向index.php
文件!
Please assist me to have correction .htaccess
code. 请协助我获取更正的.htaccess
代码。
I resolve this problem with help in this link . 我可以在此链接的帮助下解决此问题。
Just must use !^index\\.php$
instead .
只需使用!^index\\.php$
.
correction code: 更正代码:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^up\. [NC]
RewriteCond %{THE_REQUEST} \s/+index\.php[?\s] [NC]
RewriteRule ^index\.php$ - [R=404,L,NC]
RewriteCond %{HTTP_HOST} ^up\. [NC]
RewriteCond %{REQUEST_URI} !^(/upload/?[a-z,A-Z,0-9]*)$ [NC]
RewriteRule !^index\.php$ - [R=404,L,NC]
# Hide index.php , this used for YII PHP Framework
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L,QSA]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.