Skip to content

Commit a01746b

Browse files
committed
Anti-noob device installed
should hopefully get people to rtfm
1 parent 373a10e commit a01746b

4 files changed

Lines changed: 56 additions & 19 deletions

File tree

public/.htaccess

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,39 @@
11
# Enable this line to temporarily disable the Apache rewrite cache.
22
#Header set Cache-Control "max-age=0, private, no-store, no-cache, must-revalidate"
33

4-
RewriteEngine On
4+
# Tell PHP that we are using Apache
5+
SetEnv SERVER_TYPE Apache
56

6-
# www. to non-www.
7-
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
8-
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
7+
<IfModule mod_rewrite.c>
98

10-
# Remove trailing slash from any non-directory path (canonicalization)
11-
RewriteCond %{REQUEST_FILENAME} !-d
12-
RewriteCond %{REQUEST_URI} (.+)/$
13-
RewriteRule ^ %1 [L,R=301]
9+
# Tell PHP that the mod_rewrite module is ENABLED.
10+
SetEnv HTTP_MOD_REWRITE On
1411

15-
# Dynamically rewrite base directory (see http://stackoverflow.com/questions/31062479/301-redirect-urls-that-are-also-being-rewritten)
16-
RewriteCond $0#%{REQUEST_URI} ^([^#]*)#(.*)\1$
17-
RewriteRule ^.*$ - [E=BASE:%2]
18-
19-
# Forward any requested URLs that specifically contain index.php (see http://stackoverflow.com/questions/31062479/301-redirect-urls-that-are-also-being-rewritten)
20-
RewriteCond %{THE_REQUEST} /index\.php [NC]
21-
RewriteRule ^index\.php(?:/(.*))?$ %{ENV:BASE}$1 [L,R=301,NC,NE]
22-
23-
# Send the URI to index.php (Slim routing)
24-
RewriteCond %{REQUEST_FILENAME} !-f
25-
RewriteRule ^ index.php [QSA,L]
12+
RewriteEngine On
13+
14+
# Forward all www. to non-www. Remove this rule if you want both available.
15+
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
16+
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
17+
18+
# Remove trailing slash from any non-directory path (canonicalization)
19+
RewriteCond %{REQUEST_FILENAME} !-d
20+
RewriteCond %{REQUEST_URI} (.+)/$
21+
RewriteRule ^ %1 [L,R=301]
22+
23+
# Dynamically rewrite base directory (see http://stackoverflow.com/questions/31062479/301-redirect-urls-that-are-also-being-rewritten)
24+
RewriteCond $0#%{REQUEST_URI} ^([^#]*)#(.*)\1$
25+
RewriteRule ^.*$ - [E=BASE:%2]
26+
27+
# Forward any requested URLs that specifically contain index.php (see http://stackoverflow.com/questions/31062479/301-redirect-urls-that-are-also-being-rewritten)
28+
RewriteCond %{THE_REQUEST} /index\.php [NC]
29+
RewriteRule ^index\.php(?:/(.*))?$ %{ENV:BASE}$1 [L,R=301,NC,NE]
30+
31+
# Send the URI to index.php (Slim routing)
32+
RewriteCond %{REQUEST_FILENAME} !-f
33+
RewriteRule ^ index.php [QSA,L]
2634

35+
</IfModule>
36+
2737
# Deny access to any php.ini files
2838
<Files php.ini>
2939
Order allow,deny

public/images/eniac.png

420 KB
Loading

public/index.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,20 @@
55

66
// Front page
77
$app->get('/', function () use ($app) {
8+
// This if-block detects if mod_rewrite is enabled.
9+
// This is just an anti-noob device, remove it if you know how to read the docs and/or breathe through your nose.
10+
if ($_SERVER['SERVER_TYPE'] && ($_SERVER['SERVER_TYPE'] == "Apache") && !isset($_SERVER['HTTP_MOD_REWRITE'])) {
11+
$app->render('common/bad-config.html', [
12+
'page' => [
13+
'author' => $app->site->author,
14+
'title' => "Server Misconfiguration",
15+
'description' => "Your server doesn't seem to be properly configured for UserFrosting.",
16+
'alerts' => $app->alerts->getAndClearMessages()
17+
]
18+
]);
19+
exit;
20+
}
21+
822
// Forward to installation if not complete
923
if (!isset($app->site->install_status) || $app->site->install_status == "pending"){
1024
$app->redirect($app->urlFor('uri_install'));
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
{% include 'common/components/head.html' %}
4+
<body>
5+
<div class="container text-center">
6+
<h1>Your server doesn't seem to be configured properly.</h1>
7+
<img src="{{site.uri.image}}eniac.png">
8+
<br><br>
9+
<p class="lead">Specifically, it looks like you are using Apache but don't have the <code>mod_rewrite</code> module enabled. Please see the <a href="http://www.userfrosting.com/troubleshooting/#blank-page">troubleshooting guide</a> to get this sorted out.</p>
10+
</div> <!-- /container -->
11+
{% include 'common/components/footer.html' %}
12+
</body>
13+
</html>

0 commit comments

Comments
 (0)