KNOWNHOST WIKI

User Tools

Site Tools


software:how-to-fix-sandy-installation-mod-rewrite-error

Sendy Installation Mod_Rewrite Error


You may be getting a warning regarding the Apache module mod_rewrite not enabled when preparing to install Sendy. Mod_Rewrite is enabled on Knownhost servers by default.

You can check as root via SSH using the following command:

httpd -M | grep -i rewrite

You can also confirm this by adding a redirect to google.com in your sendy .htaccess file and then testing with curl to ensure that the redirect works.

First, edit the Sendy .htaccess file like below:

root@host [/home/user/public_html]# cat sendy/.htaccess
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://google.com/$1 [R,L]
root@host [/home/user/public_html]#

Then use curl to test that the redirect works:

[root]$ curl -Il domain.com/sendy/
HTTP/1.1 302 Found
Date: Fri, 03 May 2019 05:44:57 GMT
Server: Apache
Location: https://google.com/
Content-Type: text/html; charset=iso-8859-1
[root]$ 

As you can see, it does, so this means that the reported error is ironically erroneous itself.

The issue here is that for some reason, it seems that Sendy wrote their compatibility script to rely on the server using DSO as the PHP Handler1). LSAPI is now available and a more efficient PHP Handler, so we may start to see this error more frequently.

As stated via https://github.com/nette/examples/issues/17 : — function apache_get_modules is used to detect mod_rewrite, but this is not reliable way, because this works only when PHP is installed as an Apache module. So it doesn't work with fastCGI, FPM or nginx configurations.

This is also true with LSAPI configurations.

The following software completely removed the check since it would fail: — https://github.com/octobercms/october/issues/3673

If you were to write a PHP script to test, the module will show as undefined in your configuration if you are using LSAPI, FCGI, suPHP, CGI, or PHP-FPM instead of DSO:

root@host [/home/user/public_html]# tail error_log
[03-May-2019 10:59:22 Asia/Karachi] PHP Fatal error:  Call to undefined function apache_get_modules() in /home/user/public_html/test1.php on line 2
[03-May-2019 11:00:39 Asia/Karachi] PHP Fatal error:  Call to undefined function apache_get_modules() in Command line code on line 1
[03-May-2019 11:01:24 Asia/Karachi] PHP Fatal error:  Call to undefined function apache_get_modules() in Command line code on line 1
[03-May-2019 11:05:56 Asia/Karachi] PHP Fatal error:  Call to undefined function apache_get_modules() in Command line code on line 1
root@host [/home/user/public_html]#

You can check your PHP handlers on cPanel using the following command:

/usr/local/cpanel/bin/rebuild_phpconf --current

With DirectAdmin, use the following to print the versions and their handlers as set in the options.conf:

grep 'php[1/2/3/4]' /usr/local/directadmin/custombuild/options.conf

Regarding Sendy, please see their response: 2)


Hi @lewis,

If you're able to login without getting a 404 error, you have mod_rewrite enabled. You don't have to worry about it.

The reason why the mod_rewrite is yellow instead of red in your compatibility checklist is because mod_rewrite cannot be detected on some hosts. But that does not mean you don't have mod_rewrite enabled.

mod_rewrite is needed to rewrite URLs so that they don't need the .php extension appended in URLs (also known as 'pretty URLs').

If you're able to login and use Sendy without issues or 404 errors, you have mod_rewrite enabled and don't have to worry about it being labelled yellow in your compatibility checklist.

Thanks.

Best regards, Ben


So, the issue doesn't appear to be the Mod_Rewrite module as suggested, but rather a logical error in the way Sendy checks for the module as previously described. The conclusion here is that you are safe to proceed with installing Sendy despite this warning.

software/how-to-fix-sandy-installation-mod-rewrite-error.txt · Last modified: 2019/09/17 15:50 by Karson N.