简体   繁体   English

无法使用htaccess,1and1设置根目录头

[英]Unable to set root directory headers with htaccess, 1and1

My issue is that I cannot move my .htaccess file one directory back eg ../ due to hosting limitations... 我的问题是,由于托管限制,我无法将我的.htaccess文件移回一个目录,例如../。

Here is my .htaccess 这是我的.htaccess

Options -Indexes

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?gw2pvp\.com$
RewriteCond %{REQUEST_URI} !/main/
RewriteRule (.*) /main/$1 [L]

Header always set X-FRAME-OPTIONS "DENY"
Header always set X-XSS-Protection "1; mode=block"
Header always set X-Content-Type-Options "nosniff"
Header always set Content-Security-Policy "script-src 'self' //ajax.googleapis.com"

What this is doing is setting /main as the root directory, so that when i goto the main website my files in /main are shown instead. 这是在将/ main设置为根目录,因此当我转到主网站时,将显示/ main中的文件。

The issue here is that my headers won't set now. 这里的问题是我的标题现在不会设置。 Is there anyway to trick it into setting headers here? 无论如何,是否可以在这里设置标题?

My website: http://gw2pvp.com loading http://gw2pvp.com/sdgshsg will load correct headers.... (non existant directory) going into http://gw2pvp.com/main/ doesn't work either. 我的网站: http : //gw2pvp.com加载http://gw2pvp.com/sdgshsg将加载正确的标头。...(不存在的目录)进入http://gw2pvp.com/main/也不起作用。

i guess this rules out the possibility of cloudflare being the issue, and also that the directives work in htaccess. 我猜想这排除了cloudflare成为问题的可能性,并且该指令也可以在htaccess中使用。

one thing i noticed is that it works for everything but PHP files... 我注意到的一件事是,它适用于PHP文件以外的所有文件...

eg http://gw2pvp.com/main/test.html works. 例如http://gw2pvp.com/main/test.html可以工作。

this would indiciate that this is working fine and something else is not letting me set headers here.. 这将indiciate,这是工作的罚款和其他东西是不是让我在这里设置头..

Try these rules: 尝试以下规则:

Options -Indexes
RewriteEngine on

RewriteCond %{HTTP_HOST} ^(www\.)?stackoverflow\.com$
RewriteCond %{REQUEST_URI} !/forum/
RewriteRule (.*) /forum/$1 [L]

RewriteCond %{HTTP_USER_AGENT} libwww-perl.* 
RewriteRule ^ - [F,L]

%{HTTP_HOST} matches only hostname without protocol or scheme. %{HTTP_HOST}仅匹配主机名,而没有协议或方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM