[英]subdomain wildcard .htaccess for escape cloudflare
我有example.com
域,并设置为cloudflare。 但是有一段时间我不需要使用cloudflare,因此我创建了up.example.com
子域,并且没有使用它的cloudflare。 然后我将其停放在主域名上。 这意味着example.com
和up.example.com
指向根站点。 现在,对于SEO中重复的内容,我需要一个.htaccess
文件。
这些项目对我很重要:
upload
控制器的所有地址都必须可以从子域访问。 例如:up.example.com/upload/ 为此,我在这里编写代码:
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]
但是在这段代码中,我的问题是:
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.
,但必须将其打开。 注意:关于另一个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.
错误消息,在此错误消息中完全指向/upload/test.jpg
但在错误消息中指向up.example.com/upload/test
指向index.php
文件!
请协助我获取更正的.htaccess
代码。
我可以在此链接的帮助下解决此问题。
只需使用!^index\\.php$
.
更正代码:
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.