Skip to content
This repository was archived by the owner on Mar 19, 2024. It is now read-only.

Commit ea255c0

Browse files
committed
made the startpage work when mod_rewrite is not available
1 parent e97e7fa commit ea255c0

File tree

1 file changed

+28
-16
lines changed

1 file changed

+28
-16
lines changed

Diff for: web/.htaccess

+28-16
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,48 @@
1+
# Use the front controller as index file. It serves as fallback solution when
2+
# every other rewrite/redirect fails (e.g. in an aliased environment without
3+
# mod_rewrite). Additionally, this reduces the matching process for the
4+
# startpage (path "/") because otherwise Apache will apply the rewritting rules
5+
# to each configured DirectoryIndex file (e.g. index.php, index.html, index.pl).
6+
DirectoryIndex app.php
7+
18
<IfModule mod_rewrite.c>
29
RewriteEngine On
310

4-
# This reduces the matching process for the startpage (path "/") because
5-
# otherwise apache will apply the rewritting rules to each configured
6-
# DirectoryIndex file needlessly (e.g. index.php, index.html, index.pl).
7-
DirectoryIndex
8-
911
# Redirect to URI without front controller to prevent duplicate content
1012
# (with and without `/app.php`). Only do this redirect on the initial
11-
# rewrite by apache and not on subsequent cycles. Otherwise we would get an
13+
# rewrite by Apache and not on subsequent cycles. Otherwise we would get an
1214
# endless redirect loop (request -> rewrite to front controller ->
1315
# redirect -> request -> ...).
14-
# So in case you get a "too many redirects" error because your apache does
15-
# not expose the REDIRECT_STATUS environment variable, you have 2 choices:
16+
# So in case you get a "too many redirects" error or you always get redirected
17+
# to the startpage because your Apache does not expose the REDIRECT_STATUS
18+
# environment variable, you have 2 choices:
1619
# - disable this feature by commenting the following 2 lines or
17-
# - use apache >= 2.3.9 and replace all L flags by END flags and remove the
20+
# - use Apache >= 2.3.9 and replace all L flags by END flags and remove the
1821
# following RewriteCond (best solution)
1922
RewriteCond %{ENV:REDIRECT_STATUS} ^$
2023
RewriteRule ^app\.php(/(.*)|$) %{CONTEXT_PREFIX}/$2 [R=301,L]
2124

2225
# If the requested filename exists, simply serve it.
23-
# We only want to let apache serve files and not directories.
26+
# We only want to let Apache serve files and not directories.
2427
RewriteCond %{REQUEST_FILENAME} -f
2528
RewriteRule .? - [L]
2629

27-
# The following rewrites all other queries to app.php. The
28-
# condition ensures that if you are using Apache aliases to do
29-
# mass virtual hosting, the base path will be prepended to
30-
# allow proper resolution of the app.php file; it will work
31-
# in non-aliased environments as well, providing a safe, one-size
32-
# fits all solution.
30+
# The following rewrites all other queries to the front controller. The
31+
# condition ensures that if you are using Apache aliases to do mass virtual
32+
# hosting, the base path will be prepended to allow proper resolution of the
33+
# app.php file; it will work in non-aliased environments as well, providing
34+
# a safe, one-size fits all solution.
3335
RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$
3436
RewriteRule ^(.*) - [E=BASE:%1]
3537
RewriteRule .? %{ENV:BASE}app.php [L]
3638
</IfModule>
39+
40+
<IfModule !mod_rewrite.c>
41+
<IfModule mod_alias.c>
42+
# When mod_rewrite is not available, we instruct a temporary redirect of
43+
# the startpage to the front controller explicitly so that the website
44+
# and the generated links can still be used.
45+
RedirectMatch 302 ^/$ /app.php/
46+
# RedirectTemp cannot be used instead
47+
</IfModule>
48+
</IfModule>

0 commit comments

Comments
 (0)