简体   繁体   中英

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...

Here is my .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.

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.

i guess this rules out the possibility of cloudflare being the issue, and also that the directives work in htaccess.

one thing i noticed is that it works for everything but PHP files...

eg http://gw2pvp.com/main/test.html works.

this would indiciate that this is working fine and something else is not letting me set headers here..

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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