Issues access a CakePhp site after migrating to apache 2.4.10 - apache

I recently migrated a cakePHP app to another debian version but getting the above error. The apache version is 2.4 and below is what i have in the htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
On the browser it displays the following error;
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at sysad#sysad.com to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
When I check, the apache logs I get the following
htaccess: FilterProvider takes three arguments, filter-name provider-name match-expression,

Its fixed, replaced the FilterPovider mod_deflate.c with the following below
<IfModule mod_deflate.c>
SetOutputFilter DEFLATE
SetEnvIfNoCase Request_URI \.(?:gif|jpg|png|ico|zip|gz|mp4|flv)$ no-gzip
</IfModule>

Related

.htaccess is ignored on Apache

I've made a website in PHP, tested it locally and it works fine. Now I pushed it to my actual webserver and now I'm having trouble, because my .htaccess - file should redirect all calls, but it's getting ignored.
This is my .htaccess - file
AddDefaultCharset UTF-8
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
RewriteRule ^(controllers/|core/|models/|views/) - [F,L,NC]
</IfModule>
I've already searched for a solution and came up with running these commands:
a2enmod rewrite
a2enmod expires
a2ensite default-ssl
After each command i restarted the server.
The last command in the list above gives me an error:
apache2: Syntax error on line 224 of /etc/apache2/apache2.conf: Syntax error on line 166 of /etc/apache2/sites-enabled/default-ssl.conf: Expected </VirtualHost> but saw </IfModule>
Action 'configtest' failed.
Does someone have a solution for this?
Look in your /etc/apache2/sites-enabled/default-ssl.conf file. Does it have one <VirtualHost> opening entry without the corresponding </VirtualHost> closing entry?

501 error with baikal / calDAV

I found some calDAV / sabre / baikal related questions and answers here at stackoverflow, so this might be the appropriate place for my question.
I set up a baikal-flat server at my domain, hosted at one.com.
My .htaccess lives at /baikal and looks like this
# Allow HTTP headers with Apache/FastCGI
# See http://code.google.com/p/sabredav/wiki/Authentication#Apache_+_(Fast)CGI
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
</IfModule>
<IfModule mod_expires.c>
ExpiresActive Off
</IfModule>
RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteCond %{REQUEST_URI} baikal
RewriteRule ^(.*)$ https://www.<mydomain>.com/baikal/$1 [R,L]
Rewriting to ssl works now, I get https connections to baikal's web interface. Accessing it via korganizer, thunderbird and android fails - I tried any thinkable address combination. My first attempt was with
https://.com/baikal/cal.php/calendars//default/
I get a 501 error.
When I do
curl -so - --digest --user <username>:<password> https://<mydomain>.com/baikal/cal.php/calendars/<username>/default
for debugging, this is the result:
<?xml version="1.0" encoding="utf-8"?>
<d:error xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
<s:exception>Sabre\DAV\Exception\NotImplemented</s:exception>
<s:message>GET is only implemented on File objects</s:message>
<s:sabredav-version>1.8.7</s:sabredav-version>
</d:error>
I found google hits on that messages, but they seem to be iphone-related.
<username>, <mydomain> and <password>
is replaced by the real items without brackets in the real files. (-;
Could someone give me a hint?
Greetings,
Wolf
This error message is expected. GET requests don't work by default on collections.
Try a PROPFIND request if you want to see a real response coming back.

Passenger Apache Rails 403 forbidden. 2 Urls pointing to the same app 1 works other doesnt

I have a strange problem where I have two separate urls pointing to the same Rails application
staging.abcxyz.com
staging.abcttt.com
My setup runs apache with passenger. The important thing to note here is that both urls point to the same Rails application in the Document Root directory and are just served by a different urls internally.
Problem
When i try to access staging.abcxyz.com it works and the application is rendered and everything works as expected.
When i try to access staging.abcttt.com apache returns a 403 forbidden.
Apache Config
This is apache configuration of the url that doesn't work for me. Its exactly the same as the one that works expect for changes in the urls.
&ltVirtualHost *:80&gt
ServerName staging.abcttt.com
ServerAlias www.staging.abcttt.com
DocumentRoot /srv/abcxyz/current/public/
&ltDirectory /srv/abcxyz/current/public/&gt
Order allow,deny
Allow from all
Options FollowSymLinks
AllowOverride None
&lt/Directory&gt
RewriteEngine on
RewriteRule ^/$ /s/home [P]
RailsAutoDetect On
RackEnv staging
RailsEnv staging
RailsSpawnMethod smart
## PassengerAppGroupName
#
# By default, Passenger groups applcations by the the path they are served out of,
# ie /srv/yourapp/current.
#
# At times, it may be useful be serving the same app from multiple vhosts, but have
# them be have different workers. For example, you may have a /ping URL that needs to
# respond quickly, without being affected by the rest of the app. In this case, you can:
#
# * create a new vhost pointing at the same app
# * set PassengerAppGroupName to ping
# * configure a proxy to forward /ping to the new vhost
PassengerAppGroupName abcxyz
# Deflate
&ltIfModule mod_deflate.c&gt
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/x-javascript application/javascript application/json
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
&lt/IfModule&gt
RequestHeader set X-Request-Start "%t"
RewriteEngine On
# Check for maintenance file and redirect all requests
ErrorDocument 503 /system/maintenance.html
RewriteCond %{REQUEST_URI} !\.(css|jpg|png|gif)$
RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
RewriteRule ^.*$ /system/maintenance.html [R=503,L]
# Rewrite index to check for static
RewriteCond %{THE_REQUEST} ^(GET|HEAD)
RewriteCond %{DOCUMENT_ROOT}/index.html -f
RewriteRule ^/?$ /index.html [QSA,L]
# Rewrite to check for Rails non-html cached pages (i.e. xml, json, atom, etc)
RewriteCond %{THE_REQUEST} ^(GET|HEAD)
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f
RewriteRule ^(.*)$ $1 [QSA,L]
# Rewrite to check for Rails cached html page
RewriteCond %{THE_REQUEST} ^(GET|HEAD)
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI}.html -f
RewriteRule ^(.*)$ $1.html [QSA,L]
&lt/VirtualHost&gt
Questions
I don't understand why this would be a permissions issue because staging.abcxyz.com can already access the folder. Am i missing something here since both are served from the same directory
Could it be something to do the with the PassengerAppGroupName - but i'm not particularly concerned about having a separate worker send respond to a particular request
I'd really appreciate any help on this. Thanks.
Update
A thing that i notice is if I use the R [redirect] flag instead of the P [proxy] the application works and redirects to the right url but i want to be an internal redirect which does not reflect on the browser.

Why I do I get 403 Forbidden when viewing files affected by Apache RewriteRule if I have `Options -FollowSymLinks`?

I wanted to serve .xhtml files as
application/xhtml+xml if the browser says that it accepts it.
text/html otherwise
Then, I had this code:
<Files "*.xhtml">
RewriteEngine on
RewriteCond %{HTTP:Accept} !application/xhtml\+xml
RewriteRule .* - [T=text/html]
</Files>
And it worked well.
The problem is that, after disabling FollowSymLinks (I don't use symbolic links), instead of the .xhtml file I get 403 Forbidden error.
Why? Is RewriteRule .* - [T=text/html] a symbolic link?

.Htaccess - Server error

I'm getting the following error
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there was an error in a CGI script.
If you think this is a server error, please contact the webmaster.
Error 500
184.82.228.38
Mon Jan 9 02:48:12 2012
Apache/2.2.21 (Unix) DAV/2 mod_ssl/2.2.21 OpenSSL/1.0.0c PHP/5.3.8 mod_apreq2-20090110/2.7.1 mod_perl/2.0.5 Perl/v5.10.1
Im running a XAMPP server
here is my htaccess file, i don't understand what the problem is.
AuthType Basic
AuthName "Members Area"
AuthUserFile /opt/lampp/htdocs/.htpasswd
Require valid-user
<FilesMatch "(async-upload\.php|wp-cron\.php|xmlrpc\.php)$">
Satisfy Any
Order allow,deny
Allow from all
Deny from none
</FilesMatch>
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /members/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /members/index.php [L]
</IfModule>
# END WordPress
I got the same error before and the problem is the location path of the .htpasswd. Make sure you have set the correct path for that file.
I got the same error. It was due to incorrect path of .htpassswd file.
To know current directory path you can use following
echo dirname(__FILE__);
Try to copy your .htaccess and other files to some Internet webhosting and see, if the problem exists there. If not, then you'll be sure that this is purely XAMPP problem. I heard many times that it works really purely about .htaccess run locally.
For example, I don't have working autorization using .htaccess locally, because right after I provide correct login and password I see exactly the same error message as you mentioned. As for me, I'm more than sure that this problem is purely related to incorrect interpretation of .htaccess done by XAMPP (as everything works like a charm on production server), not by some mistakes in .htaccess contents.
I wasted (too) many hours on finding solution and left it. For right now, if I'm developing locally, I rename ".htaccess" to "htaccess", so it is ignored by XAMPP (Apache on-board of it) and re-enable it only when deploing files to production server. This approach maybe isn't to professional, but it saved me a lot of time and stress! :]
On the other hand, if your hosting also fail with the same symptoms, then you'll know, that this is not XAMPP releated problem and you have something wrong with your syntax.
Take a look here for a similar problem reported on StackOverflow.com, where (as I think) the cause is the same as in your issue.
Make sure that your script have the shebang line has the correct path.
Like,
Xamppinstalleddrive:\xampp\perl\bin\perl.exe
I know that this post is old as a mole, but it helped me find my answer still. So I thought, that I would share my solution anyhow.
My problem was, that I had a .htaccess-file in the htdocs-folder. When I moved/renamed it, then it worked.
My .htaccess-file looked like this:
Header add "disablevcache" "true"
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
RewriteCond %{HTTP_HOST} !^www.COMPANYNAME.dk$ [NC]
RewriteRule ^(.*)$ http://www.COMPANYNAME.dk/$1 [R,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) /404.php [R=301,L]
RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteRule ^(.*)index.php$ http://www.COMPANYNAME.dk/$1 [R=301,L]
ErrorDocument 404 /404.php
ExpiresActive On
ExpiresDefault "access plus 7200 seconds"
Header unset ETag
FileETag None
<ifmodule mod_deflate.c>
SetOutputFilter DEFLATE
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
Header append Vary User-Agent env=!dont-vary
</ifmodule>
Delete the .htaccess file and let wordpress create a new one for you[This is if you are running a wordpress site].
Things will be up and running.I had the same issue and got it sorted
I know this is old but this worked for me. How to use htpasswd to create protected directories XAMPP / apache
Essentially, you need to put the OS dir of the htpasswrd file (which is outside htdocs for security reasons). Apache can read your file system, you just have to tell it where the file is.
Disabling htaccess solved the problem for me just now. (Thanks community.) However, rather than subtly deleting the ".", I changed the file name to ".htaccess.disabled".
It achieves the same thing, but it's much easier to spot if I forget to re-enable it later. (I think all of us here can think of a time when hours were wasted because of a missing punctuation mark.)
I solved after just disabling a module:
sudo a2enmod -d deflate
Killing apache and restarting the apache service.
Maybe disabling recent enabled modules solve your problem.