Forum Moderators: phranque

Message Too Old, No Replies

406 Not Acceptable with htaccess rewrite

         

mihomes

6:38 pm on Sep 11, 2015 (gmt 0)

10+ Year Member



I am trying out a flat file blogging platform. I cannot for the life of me figure out why this rewrite is causing a 406 error even though the page shows correctly. Any ideas? It has to be something simple/dumb?

Brief background :

- subdomain is blog.example.com which is /public_html/blog/ in the file system

I have the following in the htaccess under /public_html/blog/ which basically says if a file or directory is not in the file system rewrite to index.php. Removing this and the error goes away, but of course the page no longer display properly.

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>


GET http://blog.example.com/ 406 Not Acceptable
blog.example.com

response headers :

Cache-Controlno-store, no-cache, must-revalidate, post-check=0, pre-check=0, private, no-cache, no-store, must-revalidate, max-age=0
ConnectionKeep-Alive
Content-Encodinggzip
Content-Languageen-US
Content-Length4042
Content-Typetext/html; charset=utf-8
Date Fri, 11 Sep 2015 18:34:53 GMT
ExpiresThu, 19 Nov 1981 08:52:00 GMT, Wed, 11 Jan 1984 05:00:00 GMT
Keep-Alivetimeout=5, max=99
Pragmano-cache, no-cache
ServerApache
VaryAccept-Encoding
X-Powered-ByPHP/5.5.28

request headers :

Accepttext/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encodinggzip, deflate
Accept-Languageen-US,en;q=0.5
Connectionkeep-alive
DNT1
Host blog.example.com
User-AgentMozilla/5.0 (Windows NT 10.0; WOW64; rv:40.0) Gecko/20100101 Firefox/40.0

whitespace

7:44 pm on Sep 11, 2015 (gmt 0)

10+ Year Member Top Contributors Of The Month



RewriteRule . /index.php [L]


The single dot matches 1 char in the URL path. When you request the document root (ie. blog.example.com/) this URL path is empty in .htaccess context (since the directory prefix - a single slash - is removed), so it doesn't match and your front controller does not fire.

lucy24

8:55 pm on Sep 11, 2015 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



GET http://blog.example.com/ 406 Not Acceptable

Does it only happen when you request the root, as whitespace observes, or did you just pick this line at random? I've got an uneasy notion that the . vs. .? aspect is just a red herring, because surely there's a DirectoryIndex line elsewhere that would result in "index.php" getting internally requested anyway.

mihomes

2:34 am on Sep 12, 2015 (gmt 0)

10+ Year Member



Turned out a mod security rule was being triggered. Once I manually excluded the rule everything was fine.