Hi there,

Apache gives me 404 error when asking for /user - why?

When removing Boost line from .htaccess everything works fine. But when I put generated Boost content into .htaccess I see in log:

... "GET /user HTTP/1.1" 404 7343 "http://www.mydrupalsite.com/user" ...

Important - I still have login form on page. So it looks like a regular /user page, but in the Apache log I can see 404. How come? :) When I try to log in nothing happens - site is only reloaded, again with 404 code.

This is what I put into .htaccess - is everything ok with it?

  ### BOOST START ###


  # Allow for alt paths to be set via htaccess rules; allows for cached variants (future mobile support)
  RewriteRule .* - [E=boostpath:normal]


#  # Apache 2.4 bug workaround
#  # Enables Search from home page https://drupal.org/node/2078595#comment-8724321
#  RewriteCond %{REQUEST_METHOD} ^(POST)$
#  RewriteCond %{REQUEST_URI} /
#  RewriteRule .* / [S=3]


  # Caching for anonymous users
  # Skip boost IF not get request OR uri has wrong dir OR cookie is set OR request came from this server OR https request
  RewriteCond %{REQUEST_METHOD} !^(GET|HEAD)$ [OR]
  RewriteCond %{REQUEST_URI} (^/(admin|cache|misc|modules|sites|system|openid|themes|node/add|comment/reply))|(/(edit|user|user/(login|password|register))$)
  RewriteCond %{HTTPS} on [OR]
  RewriteCond %{HTTP_COOKIE} DRUPAL_UID [OR]
  RewriteCond %{ENV:REDIRECT_STATUS} 200
  RewriteRule .* - [S=2]


#  # Apache 2.4 bug workaround
#  # Enables caching of index/ home page
#  RewriteCond %{REQUEST_URI} ^/index\.php$
#  RewriteCond %{DOCUMENT_ROOT}/cache/%{ENV:boostpath}/%{HTTP_HOST}/\_%{QUERY_STRING}\.html -s
#  RewriteRule .* cache/%{ENV:boostpath}/%{HTTP_HOST}/\_%{QUERY_STRING}\.html [L,T=text/html]


  # NORMAL
  RewriteCond %{DOCUMENT_ROOT}/cache/%{ENV:boostpath}/%{HTTP_HOST}%{REQUEST_URI}_%{QUERY_STRING}\.html -s
  RewriteRule .* cache/%{ENV:boostpath}/%{HTTP_HOST}%{REQUEST_URI}_%{QUERY_STRING}\.html [L,T=text/html]


  ### BOOST END ###

Thanks.

Szy.

PS. Drupal 7 last stable, or last dev with Boost last stable or last dev - no difference.

Comments

szy’s picture

Issue summary: View changes
szy’s picture

Issue summary: View changes
Anonymous’s picture

RewriteCond %{REQUEST_URI} (^/(admin|cache|misc|modules|sites|system|openid|themes|node/add|comment/reply))|(/(edit|user|user/(login|password|register))$)

boost does not serve the user page ever (as the rule above shows. Otherwise one could end up with a username filled out from a failed log in attempt and it would be a security issue, at a guess I would say that the boost rules are either in the wrong place in the .htaccess file, or rules are being applied somewhere else and causing a failure on the S=n section which "skip" rewrite rules. It may also be that you are one of those affected by the apache 2.4 problems with rewrite rules and in which case we'd need a lot more details as this would be a new bug requiring a new workaround.

baronmunchowsen’s picture

I'm having this issue too with all user, admin pages. No forms submit (user or admin) - page reloads and I see a 404 log in my browser console.
Boost Rules are applied to a clean .htaccess file.
Boost Version 7.x-1.x-dev - 2014-May-04
Apache version 2.2.24

--edit--
While the non-admin pages are being cached and served by boost, the first time a page is accessed (before the page has been cached by boost) I also see a 404 error in the console for that particular page. Once boost serves the cached version, the 404 error no longer presents itself.

Anonymous’s picture

can you attach your .htaccess?

thank you.

baronmunchowsen’s picture

Apologies for the delay.
Yes - here are the boost rules (in an otherwise untouched drupal .htaccess file)

  ### BOOST START ###

  # Allow for alt paths to be set via htaccess rules; allows for cached variants (future mobile support)
  RewriteRule .* - [E=boostpath:normal]

#  # Apache 2.4 bug workaround
#  # Enables Search from home page https://drupal.org/node/2078595#comment-8724321
#  RewriteCond %{REQUEST_METHOD} ^(POST)$
#  RewriteCond %{REQUEST_URI} /
#  RewriteRule .* / [S=4]

  # Caching for anonymous users
  # Skip boost IF not get request OR uri has wrong dir OR cookie is set OR request came from this server OR https request
  RewriteCond %{REQUEST_METHOD} !^(GET|HEAD)$ [OR]
  RewriteCond %{REQUEST_URI} (^/(admin|cache|misc|modules|sites|system|openid|themes|node/add|comment/reply))|(/(edit|user|user/(login|password|register))$) [OR]
  RewriteCond %{HTTPS} on [OR]
  RewriteCond %{HTTP_COOKIE} DRUPAL_UID [OR]
  RewriteCond %{ENV:REDIRECT_STATUS} 200
  RewriteRule .* - [S=3]

#  # Apache 2.4 bug workaround
#  # Enables caching of index/ home page
#  RewriteCond %{REQUEST_URI} ^/index\.php$
#  RewriteCond %{DOCUMENT_ROOT}/cache/%{ENV:boostpath}/%{HTTP_HOST}/\_%{QUERY_STRING}\.html -s
#  RewriteRule .* cache/%{ENV:boostpath}/%{HTTP_HOST}/\_%{QUERY_STRING}\.html [L,T=text/html]

  # NORMAL
  RewriteCond %{DOCUMENT_ROOT}/cache/%{ENV:boostpath}/%{HTTP_HOST}%{REQUEST_URI}_%{QUERY_STRING}\.html -s
  RewriteRule .* cache/%{ENV:boostpath}/%{HTTP_HOST}%{REQUEST_URI}_%{QUERY_STRING}\.html [L,T=text/html]
  RewriteCond %{DOCUMENT_ROOT}/cache/%{ENV:boostpath}/%{HTTP_HOST}%{REQUEST_URI}_%{QUERY_STRING}\.json -s
  RewriteRule .* cache/%{ENV:boostpath}/%{HTTP_HOST}%{REQUEST_URI}_%{QUERY_STRING}\.json [L,T=text/javascript]

  ### BOOST END ###

Anonymous’s picture

RewriteRule .* - [S=3]

should be

RewriteRule .* - [S=2]

I think. The rules should be compared with the output that boost generates to paste in.

baronmunchowsen’s picture

That seems to do the trick. Boost generates S=3, but replacing with S=2 fixes the issue.
Many thanks

szy’s picture

Then I reverted back to Boost 1.0 to use it.

Now, back to last dev and still have this horrible 404 for /user. #7 didn't help.

Probably more of you have it too, but you can't see this 404 in console. Because you still see the login page, so you don't even think, that loaded page gives 404 in console. Crazy.

Any other hint, please?

Szy.

Anonymous’s picture

Apache version, a log file showing it and then the next line which should be a redirect to index.php and the .htaccess file please. (although technically all drupal requests are 404 as /user doesn't exist it's just a rewrite.

szy’s picture

Apache 2.2.16, Debian, Varnish, Memcache.

This is a *single* visit at /user - yes, it gives two lines in the log:

m.y.i.p - - [18/Apr/2015:00:06:44 +0200] "GET /user HTTP/1.1" 404 7258 "-" "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 Safari/537.36 OPR/28.0.1750.51"
m.y.i.p - - [18/Apr/2015:00:06:44 +0200] "GET /user HTTP/1.1" 404 7271 "http://www.drup.al/user" "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 Safari/537.36 OPR/28.0.1750.51"

And the part of .htaccess - when I remove it, it works again:

  ### BOOST START ###

  # Allow for alt paths to be set via htaccess rules; allows for cached variants (future mobile support)
  RewriteRule .* - [E=boostpath:normal]

#  # Apache 2.4 bug workaround
#  # Enables Search from home page https://drupal.org/node/2078595#comment-8724321
#  RewriteCond %{REQUEST_METHOD} ^(POST)$
#  RewriteCond %{REQUEST_URI} /
#  RewriteRule .* / [S=3]

  # Caching for anonymous users
  # Skip boost IF not get request OR uri has wrong dir OR cookie is set OR request came from this server OR https request
  RewriteCond %{REQUEST_METHOD} !^(GET|HEAD)$ [OR]
  RewriteCond %{REQUEST_URI} (^/(admin|cache|misc|modules|sites|system|openid|themes|node/add|comment/reply))|(/(edit|user|user/(login|password|register))$)
  RewriteCond %{HTTPS} on [OR]
  RewriteCond %{HTTP_COOKIE} DRUPAL_UID [OR]
  RewriteCond %{ENV:REDIRECT_STATUS} 200
  RewriteRule .* - [S=2]

#  # Apache 2.4 bug workaround
#  # Enables caching of index/ home page
#  RewriteCond %{REQUEST_URI} ^/index\.php$
#  RewriteCond /var/www/drup.al/cache/%{ENV:boostpath}/%{HTTP_HOST}/\_%{QUERY_STRING}\.html -s
#  RewriteRule .* cache/%{ENV:boostpath}/www.drup.al/\_%{QUERY_STRING}\.html [L,T=text/html]

  # NORMAL
  RewriteCond /var/www/drup.al/cache/%{ENV:boostpath}/www.drup.al%{REQUEST_URI}_%{QUERY_STRING}\.html -s
  RewriteRule .* cache/%{ENV:boostpath}/www.drup.al%{REQUEST_URI}_%{QUERY_STRING}\.html [L,T=text/html]

  ### BOOST END ###

Yes, I have my "drup.al" domain set there, instead of HTTPHOST, etc.

Thanks!

Szy.

Anonymous’s picture

  RewriteCond %{ENV:REDIRECT_STATUS} 200
  RewriteRule .* - [S=2]

should be

  RewriteCond %{ENV:REDIRECT_STATUS} 200
  RewriteRule .* - [S=1]
szy’s picture

Indeed! It works!

Thank you, Philip! :]

Szy.

salvadorweb89’s picture

Thanks James, it worked great!

aaldayel’s picture

#12 solved ajax problem, thanks Philip_Clarke!

prografr’s picture

Aَlso #12 solved my problem with ajax requests in Views module.