Skip to content

Commit d94fcc8

Browse files
committed
minor #1070 Require symfony/apache-pack package (bocharsky-bw)
This PR was merged into the master branch. Discussion ---------- Require symfony/apache-pack package What about to add `symfony/apache-pack` to this project? We have had a few related issues about missing it: #1069, #1005, #711 . Basically, it's a really small package that just adds `.htaccess` file into public/ dir and that's it. It would help Apache users and does not do any harm to others I think, so why not have it out of the box? Commits ------- 9a2dad5 Require symfony/apache-pack package
2 parents 4966423 + 9a2dad5 commit d94fcc8

File tree

4 files changed

+102
-1
lines changed

4 files changed

+102
-1
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"doctrine/orm": "^2.5.11",
1717
"erusev/parsedown": "^1.6",
1818
"sensio/framework-extra-bundle": "^5.1",
19+
"symfony/apache-pack": "^1.0",
1920
"symfony/asset": "5.0.*",
2021
"symfony/console": "5.0.*",
2122
"symfony/dotenv": "5.0.*",

composer.lock

Lines changed: 23 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/.htaccess

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Use the front controller as index file. It serves as a 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+
# start page (path "/") because otherwise Apache will apply the rewriting rules
5+
# to each configured DirectoryIndex file (e.g. index.php, index.html, index.pl).
6+
DirectoryIndex index.php
7+
8+
# By default, Apache does not evaluate symbolic links if you did not enable this
9+
# feature in your server configuration. Uncomment the following line if you
10+
# install assets as symlinks or if you experience problems related to symlinks
11+
# when compiling LESS/Sass/CoffeScript assets.
12+
# Options FollowSymlinks
13+
14+
# Disabling MultiViews prevents unwanted negotiation, e.g. "/index" should not resolve
15+
# to the front controller "/index.php" but be rewritten to "/index.php/index".
16+
<IfModule mod_negotiation.c>
17+
Options -MultiViews
18+
</IfModule>
19+
20+
<IfModule mod_rewrite.c>
21+
RewriteEngine On
22+
23+
# Determine the RewriteBase automatically and set it as environment variable.
24+
# If you are using Apache aliases to do mass virtual hosting or installed the
25+
# project in a subdirectory, the base path will be prepended to allow proper
26+
# resolution of the index.php file and to redirect to the correct URI. It will
27+
# work in environments without path prefix as well, providing a safe, one-size
28+
# fits all solution. But as you do not need it in this case, you can comment
29+
# the following 2 lines to eliminate the overhead.
30+
RewriteCond %{REQUEST_URI}::$0 ^(/.+)/(.*)::\2$
31+
RewriteRule .* - [E=BASE:%1]
32+
33+
# Sets the HTTP_AUTHORIZATION header removed by Apache
34+
RewriteCond %{HTTP:Authorization} .+
35+
RewriteRule ^ - [E=HTTP_AUTHORIZATION:%0]
36+
37+
# Redirect to URI without front controller to prevent duplicate content
38+
# (with and without `/index.php`). Only do this redirect on the initial
39+
# rewrite by Apache and not on subsequent cycles. Otherwise we would get an
40+
# endless redirect loop (request -> rewrite to front controller ->
41+
# redirect -> request -> ...).
42+
# So in case you get a "too many redirects" error or you always get redirected
43+
# to the start page because your Apache does not expose the REDIRECT_STATUS
44+
# environment variable, you have 2 choices:
45+
# - disable this feature by commenting the following 2 lines or
46+
# - use Apache >= 2.3.9 and replace all L flags by END flags and remove the
47+
# following RewriteCond (best solution)
48+
RewriteCond %{ENV:REDIRECT_STATUS} =""
49+
RewriteRule ^index\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L]
50+
51+
# If the requested filename exists, simply serve it.
52+
# We only want to let Apache serve files and not directories.
53+
# Rewrite all other queries to the front controller.
54+
RewriteCond %{REQUEST_FILENAME} !-f
55+
RewriteRule ^ %{ENV:BASE}/index.php [L]
56+
</IfModule>
57+
58+
<IfModule !mod_rewrite.c>
59+
<IfModule mod_alias.c>
60+
# When mod_rewrite is not available, we instruct a temporary redirect of
61+
# the start page to the front controller explicitly so that the website
62+
# and the generated links can still be used.
63+
RedirectMatch 307 ^/$ /index.php/
64+
# RedirectTemp cannot be used instead
65+
</IfModule>
66+
</IfModule>

symfony.lock

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,18 @@
171171
"ref": "fb7e19da7f013d0d422fa9bce16f5c510e27609b"
172172
}
173173
},
174+
"symfony/apache-pack": {
175+
"version": "1.0",
176+
"recipe": {
177+
"repo": "github.com/symfony/recipes-contrib",
178+
"branch": "master",
179+
"version": "1.0",
180+
"ref": "410b9325a37ef86f1e47262c61738f6202202bca"
181+
},
182+
"files": [
183+
"public/.htaccess"
184+
]
185+
},
174186
"symfony/asset": {
175187
"version": "v4.3.3"
176188
},

0 commit comments

Comments
 (0)