mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Reflect index.php change in server install docs
This commit is contained in:
parent
4a94dfe55b
commit
cea5cd1c3e
@ -62,7 +62,9 @@ control.
|
|||||||
|
|
||||||
3. Apache rewrite (mod_rewrite) isn't working and it's installed (prior to SilverStripe 3.1.11)
|
3. Apache rewrite (mod_rewrite) isn't working and it's installed (prior to SilverStripe 3.1.11)
|
||||||
|
|
||||||
Due to some changes to `mod_dir` in [Apache 2.4](http://httpd.apache.org/docs/current/mod/mod_dir.html#DirectoryCheckHandler) (precedence of handlers), index.php gets added to the URLs as soon as you navigate to the homepage of your site. Further requests are then handled by index.php rather than `mod_rewrite` (`main.php`). To fix this place the following within the `mod_rewrite` section of your .htaccess file:
|
Due to some changes to `mod_dir` in [Apache 2.4](http://httpd.apache.org/docs/current/mod/mod_dir.html#DirectoryCheckHandler) (precedence of handlers),
|
||||||
|
index.php gets added to the URLs as soon as you navigate to the homepage of your site.
|
||||||
|
To fix this place the following within the `mod_rewrite` section of your .htaccess file:
|
||||||
|
|
||||||
```
|
```
|
||||||
<IfModule mod_rewrite.c>
|
<IfModule mod_rewrite.c>
|
||||||
|
@ -24,7 +24,6 @@ On "live" environments, the `?isDev=1` solution is preferred, as it means that y
|
|||||||
|
|
||||||
Due to some changes to `mod_dir` in [Apache 2.4](http://httpd.apache.org/docs/current/mod/mod_dir.html#DirectoryCheckHandler)
|
Due to some changes to `mod_dir` in [Apache 2.4](http://httpd.apache.org/docs/current/mod/mod_dir.html#DirectoryCheckHandler)
|
||||||
(precedence of handlers), index.php gets added to the URLs as soon as you navigate to the homepage of your site.
|
(precedence of handlers), index.php gets added to the URLs as soon as you navigate to the homepage of your site.
|
||||||
Further requests are then handled by index.php rather than `mod_rewrite` (`main.php`).
|
|
||||||
To fix this place the following within the `mod_rewrite` section of your .htaccess file:
|
To fix this place the following within the `mod_rewrite` section of your .htaccess file:
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -27,11 +27,11 @@ Silverstripe. Replace "yoursite.com" and "/home/yoursite/public_html/" below.
|
|||||||
# Rewrite URLs so they are nicer
|
# Rewrite URLs so they are nicer
|
||||||
url.rewrite-once = (
|
url.rewrite-once = (
|
||||||
"^/.*\.[A-Za-z0-9]+.*?$" => "$0",
|
"^/.*\.[A-Za-z0-9]+.*?$" => "$0",
|
||||||
"^/(.*?)(\?|$)(.*)" => "/vendor/silverstripe/framework/main.php?url=$1&$3"
|
"^/(.*?)(\?|$)(.*)" => "/index.php?$3"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Show SilverStripe error page
|
# Show SilverStripe error page
|
||||||
server.error-handler-404 = "/vendor/silverstripe/framework/main.php"
|
server.error-handler-404 = "/index.php"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -53,14 +53,14 @@ of Silverstripe on the same host, you can use something like this (be warned, it
|
|||||||
url.rewrite-once = (
|
url.rewrite-once = (
|
||||||
"(?i)(/copy1/.*\.([A-Za-z0-9]+))(.*?)$" => "$0",
|
"(?i)(/copy1/.*\.([A-Za-z0-9]+))(.*?)$" => "$0",
|
||||||
"(?i)(/copy2/.*\.([A-Za-z0-9]+))(.*?)$" => "$0",
|
"(?i)(/copy2/.*\.([A-Za-z0-9]+))(.*?)$" => "$0",
|
||||||
"^/copy1/(.*?)(\?|$)(.*)" => "/copy1/vendor/silverstripe/framework/main.php?url=$1&$3",
|
"^/copy1/(.*?)(\?|$)(.*)" => "/copy1/index.php?$3",
|
||||||
"^/copy2/(.*?)(\?|$)(.*)" => "/copy2/vendor/silverstripe/framework/main.php?url=$1&$3"
|
"^/copy2/(.*?)(\?|$)(.*)" => "/copy2/index.php?$3"
|
||||||
)
|
)
|
||||||
$HTTP["url"] =~ "^/copy1/" {
|
$HTTP["url"] =~ "^/copy1/" {
|
||||||
server.error-handler-404 = "/copy1/vendor/silverstripe/framework/main.php"
|
server.error-handler-404 = "/copy1/index.php"
|
||||||
}
|
}
|
||||||
$HTTP["url"] =~ "^/copy2/" {
|
$HTTP["url"] =~ "^/copy2/" {
|
||||||
server.error-handler-404 = "/copy2/vendor/silverstripe/framework/main.php"
|
server.error-handler-404 = "/copy2/index.php"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ But enough of the disclaimer, on to the actual configuration — typically in `n
|
|||||||
}
|
}
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
try_files $uri vendor/silverstripe/framework/main.php?url=$uri&$query_string;
|
try_files $uri index.php?$query_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
error_page 404 /assets/error-404.html;
|
error_page 404 /assets/error-404.html;
|
||||||
@ -41,7 +41,7 @@ But enough of the disclaimer, on to the actual configuration — typically in `n
|
|||||||
deny all;
|
deny all;
|
||||||
}
|
}
|
||||||
sendfile on;
|
sendfile on;
|
||||||
try_files $uri vendor/silverstripe/framework/main.php?url=$uri&$query_string;
|
try_files $uri index.php?$query_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
location ~ /framework/.*(main|rpc|tiny_mce_gzip)\.php$ {
|
location ~ /framework/.*(main|rpc|tiny_mce_gzip)\.php$ {
|
||||||
|
@ -48,7 +48,7 @@ Create `/etc/nginx/silverstripe.conf` and add this configuration:
|
|||||||
fastcgi_buffers 4 32k;
|
fastcgi_buffers 4 32k;
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
try_files $uri /vendor/silverstripe/framework/main.php?url=$uri&$query_string;
|
try_files $uri /index.php?$query_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
error_page 404 /assets/error-404.html;
|
error_page 404 /assets/error-404.html;
|
||||||
@ -87,7 +87,7 @@ Create `/etc/nginx/silverstripe.conf` and add this configuration:
|
|||||||
deny all;
|
deny all;
|
||||||
}
|
}
|
||||||
|
|
||||||
The above script passes all non-static file requests to `/framework/main.php` in the webroot which relies on
|
The above script passes all non-static file requests to `/index.php` in the webroot which relies on
|
||||||
`hhvm.conf` being included prior so that php requests are handled.
|
`hhvm.conf` being included prior so that php requests are handled.
|
||||||
|
|
||||||
Now in your nginx `server` configuration you can then include the `hhvm.conf` and `silverstripe.conf` files
|
Now in your nginx `server` configuration you can then include the `hhvm.conf` and `silverstripe.conf` files
|
||||||
|
@ -362,7 +362,7 @@ bypasses PHP requests for files that do exist. The default template
|
|||||||
# Non existant files passed to requesthandler
|
# Non existant files passed to requesthandler
|
||||||
RewriteCond %{REQUEST_URI} ^(.*)$
|
RewriteCond %{REQUEST_URI} ^(.*)$
|
||||||
RewriteCond %{REQUEST_FILENAME} !-f
|
RewriteCond %{REQUEST_FILENAME} !-f
|
||||||
RewriteRule .* ../vendor/silverstripe/framework/main.php?url=%1 [QSA]
|
RewriteRule .* ../index.php [QSA]
|
||||||
```
|
```
|
||||||
|
|
||||||
You will need to ensure that your core apache configuration has the necessary `AllowOverride`
|
You will need to ensure that your core apache configuration has the necessary `AllowOverride`
|
||||||
@ -381,9 +381,9 @@ The default rule for IIS is as below (only partial configuration displayed):
|
|||||||
<match url="^(.*)$" />
|
<match url="^(.*)$" />
|
||||||
<conditions>
|
<conditions>
|
||||||
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
|
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
|
||||||
<add input="../vendor/silverstripe/framework/main.php" matchType="IsFile" />
|
<add input="../index.php" matchType="IsFile" />
|
||||||
</conditions>
|
</conditions>
|
||||||
<action type="Rewrite" url="../vendor/silverstripe/framework/main.php?url={R:1}" appendQueryString="true" />
|
<action type="Rewrite" url="../index.php" appendQueryString="true" />
|
||||||
</rule>
|
</rule>
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -402,6 +402,6 @@ dynamic requests are processed via the Framework:
|
|||||||
```
|
```
|
||||||
location ^~ /assets/ {
|
location ^~ /assets/ {
|
||||||
sendfile on;
|
sendfile on;
|
||||||
try_files $uri vendor/silverstripe/framework/main.php?url=$uri&$query_string;
|
try_files $uri index.php?$query_string;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@ -65,17 +65,19 @@ The role of the application is to:
|
|||||||
The HTTPApplication provides a specialised application implementation for handling HTTP Requests.
|
The HTTPApplication provides a specialised application implementation for handling HTTP Requests.
|
||||||
This class provides basic support for HTTP Middleware, such as [ErrorControlChainMiddleware](api:SilverStripe\Core\Startup\ErrorControlChainMiddleware).
|
This class provides basic support for HTTP Middleware, such as [ErrorControlChainMiddleware](api:SilverStripe\Core\Startup\ErrorControlChainMiddleware).
|
||||||
|
|
||||||
`main.php` contains the default application implementation.
|
The `index.php` file in your project root contains the default application implementation.
|
||||||
|
You can customise it as required.
|
||||||
|
|
||||||
|
|
||||||
```php
|
```php
|
||||||
|
<?php
|
||||||
|
|
||||||
use SilverStripe\Control\HTTPApplication;
|
use SilverStripe\Control\HTTPApplication;
|
||||||
use SilverStripe\Control\HTTPRequestBuilder;
|
use SilverStripe\Control\HTTPRequestBuilder;
|
||||||
use SilverStripe\Core\CoreKernel;
|
use SilverStripe\Core\CoreKernel;
|
||||||
use SilverStripe\Core\Startup\ErrorControlChainMiddleware;
|
use SilverStripe\Core\Startup\ErrorControlChainMiddleware;
|
||||||
|
|
||||||
require __DIR__ . '/src/includes/autoload.php';
|
require __DIR__ . '/vendor/autoload.php';
|
||||||
|
|
||||||
// Build request and detect flush
|
// Build request and detect flush
|
||||||
$request = HTTPRequestBuilder::createFromEnvironment();
|
$request = HTTPRequestBuilder::createFromEnvironment();
|
||||||
@ -88,35 +90,6 @@ This class provides basic support for HTTP Middleware, such as [ErrorControlChai
|
|||||||
$response->output();
|
$response->output();
|
||||||
```
|
```
|
||||||
|
|
||||||
Users can customise their own application by coping the above to a file in `mysite/main.php`, and
|
|
||||||
updating their `.htaccess` to point to the new file.
|
|
||||||
|
|
||||||
:::
|
|
||||||
<IfModule mod_rewrite.c>
|
|
||||||
# ...
|
|
||||||
RewriteCond %{REQUEST_URI} ^(.*)$
|
|
||||||
RewriteCond %{REQUEST_FILENAME} !-f
|
|
||||||
RewriteRule .* mysite/main.php?url=%1 [QSA]
|
|
||||||
# ...
|
|
||||||
</IfModule>
|
|
||||||
|
|
||||||
|
|
||||||
Note: This config must also be duplicated in the below template which provide asset routing:
|
|
||||||
|
|
||||||
`silverstripe-assets/templates/SilverStripe/Assets/Flysystem/PublicAssetAdapter_HTAccess.ss`:
|
|
||||||
|
|
||||||
|
|
||||||
```ss
|
|
||||||
|
|
||||||
<IfModule mod_rewrite.c>
|
|
||||||
# ...
|
|
||||||
# Non existant files passed to requesthandler
|
|
||||||
RewriteCond %{REQUEST_URI} ^(.*)$
|
|
||||||
RewriteCond %{REQUEST_FILENAME} !-f
|
|
||||||
RewriteRule .* ../mysite/main.php?url=%1 [QSA]
|
|
||||||
</IfModule>
|
|
||||||
```
|
|
||||||
|
|
||||||
## Custom application actions
|
## Custom application actions
|
||||||
|
|
||||||
If it's necessary to boot a SilverStripe kernel and application, but not do any
|
If it's necessary to boot a SilverStripe kernel and application, but not do any
|
||||||
|
@ -18,58 +18,10 @@ Check our [installation guides](/getting_started/installation) on how other web
|
|||||||
The standard SilverStripe project ships with a `.htaccess` file in your webroot for this purpose.
|
The standard SilverStripe project ships with a `.htaccess` file in your webroot for this purpose.
|
||||||
By default, requests will be passed through for files existing on the filesystem.
|
By default, requests will be passed through for files existing on the filesystem.
|
||||||
Some access control is in place to deny access to potentially sensitive files in the webroot, such as YAML configuration files.
|
Some access control is in place to deny access to potentially sensitive files in the webroot, such as YAML configuration files.
|
||||||
If no file can be directly matched, control is handed off to `framework/main.php`.
|
If no file can be directly matched, control is handed off to `index.php`.
|
||||||
|
|
||||||
### SILVERSTRIPE START ###
|
SilverStripe can also operate without this level of rewriting, in which case
|
||||||
|
you'll have `index.php` as part of the URL.
|
||||||
# Deny access to templates (but allow from localhost)
|
|
||||||
<Files *.ss>
|
|
||||||
Order deny,allow
|
|
||||||
Deny from all
|
|
||||||
Allow from 127.0.0.1
|
|
||||||
</Files>
|
|
||||||
|
|
||||||
# Deny access to IIS configuration
|
|
||||||
<Files web.config>
|
|
||||||
Order deny,allow
|
|
||||||
Deny from all
|
|
||||||
</Files>
|
|
||||||
|
|
||||||
# Deny access to YAML configuration files which might include sensitive information
|
|
||||||
<Files ~ "\.ya?ml$">
|
|
||||||
Order allow,deny
|
|
||||||
Deny from all
|
|
||||||
</Files>
|
|
||||||
|
|
||||||
# Route errors to static pages automatically generated by SilverStripe
|
|
||||||
ErrorDocument 404 /assets/error-404.html
|
|
||||||
ErrorDocument 500 /assets/error-500.html
|
|
||||||
|
|
||||||
<IfModule mod_rewrite.c>
|
|
||||||
SetEnv HTTP_MOD_REWRITE On
|
|
||||||
RewriteEngine On
|
|
||||||
|
|
||||||
# Deny access to potentially sensitive files and folders
|
|
||||||
RewriteRule ^vendor(/|$) - [F,L,NC]
|
|
||||||
RewriteRule silverstripe-cache(/|$) - [F,L,NC]
|
|
||||||
RewriteRule composer\.(json|lock) - [F,L,NC]
|
|
||||||
|
|
||||||
# Non existant files passed to requesthandler
|
|
||||||
# Try finding the module in the vendor folder first
|
|
||||||
RewriteCond %{REQUEST_URI} ^(.*)$
|
|
||||||
RewriteCond %{REQUEST_FILENAME} !-f
|
|
||||||
RewriteRule .* ../vendor/silverstripe/framework/main.php?url=%1 [QSA]
|
|
||||||
|
|
||||||
# If requesting the main script directly, rewrite to the installer
|
|
||||||
RewriteCond %{REQUEST_URI} ^(.*)/framework/main.php$
|
|
||||||
RewriteCond %{REQUEST_FILENAME} !-f
|
|
||||||
RewriteRule . %1/install.php? [R,L]
|
|
||||||
|
|
||||||
</IfModule>
|
|
||||||
### SILVERSTRIPE END ###
|
|
||||||
|
|
||||||
SilverStripe can also operate without this level of rewriting, in which case all dynamic requests go
|
|
||||||
through an `index.php` script in the webroot.
|
|
||||||
|
|
||||||
<div class="notice" markdown="1">
|
<div class="notice" markdown="1">
|
||||||
Running SilverStripe without web server based rewriting is not recommended since it
|
Running SilverStripe without web server based rewriting is not recommended since it
|
||||||
@ -86,7 +38,7 @@ tasks silently in the background.
|
|||||||
[configuration file](/getting_started/environment_management) in the webroot.
|
[configuration file](/getting_started/environment_management) in the webroot.
|
||||||
* Sets constants based on the filesystem structure (e.g. `BASE_URL`, `BASE_PATH` and `TEMP_PATH`)
|
* Sets constants based on the filesystem structure (e.g. `BASE_URL`, `BASE_PATH` and `TEMP_PATH`)
|
||||||
|
|
||||||
All requests go through `main.php`, which sets up the core [Kernel](api:SilverStripe\Core\Kernel) and [HTTPApplication](api:SilverStripe\Control\HTTPApplication)
|
All requests go through `index.php`, which sets up the core [Kernel](api:SilverStripe\Core\Kernel) and [HTTPApplication](api:SilverStripe\Control\HTTPApplication)
|
||||||
objects. See [/developer_guides/execution_pipeline/app_object_and_kernel] for details on this.
|
objects. See [/developer_guides/execution_pipeline/app_object_and_kernel] for details on this.
|
||||||
The main process follows:
|
The main process follows:
|
||||||
|
|
||||||
@ -101,13 +53,12 @@ The main process follows:
|
|||||||
|
|
||||||
While you usually don't need to modify the bootstrap on this level, some deeper customizations like
|
While you usually don't need to modify the bootstrap on this level, some deeper customizations like
|
||||||
adding your own manifests or a performance-optimized routing might require it.
|
adding your own manifests or a performance-optimized routing might require it.
|
||||||
An example of this can be found in the ["staticpublisher" module](https://github.com/silverstripe-labs/silverstripe-staticpublisher/blob/master/main.php).
|
An example of this can be found in the ["staticpublisher" module](https://github.com/silverstripe-labs/silverstripe-staticpublisher/).
|
||||||
The modules instructs web servers to route through its own `main.php` to determine which requests can be cached
|
|
||||||
before handing control off to SilverStripe's own `main.php`.
|
|
||||||
|
|
||||||
## Routing and Request Handling
|
## Routing and Request Handling
|
||||||
|
|
||||||
The `main.php` script relies on [Director](api:SilverStripe\Control\Director) to work out which [controller](../controllers/) should handle this request. It parses the URL, matching it to one of a number of patterns,
|
The `index.php` script relies on [Director](api:SilverStripe\Control\Director) to work out which [controller](../controllers/)
|
||||||
|
should handle this request. It parses the URL, matching it to one of a number of patterns,
|
||||||
and determines the controller, action and any argument to be used ([Routing](../controllers/routing)).
|
and determines the controller, action and any argument to be used ([Routing](../controllers/routing)).
|
||||||
|
|
||||||
* Creates a [HTTPRequest](api:SilverStripe\Control\HTTPRequest) object containing all request and environment information
|
* Creates a [HTTPRequest](api:SilverStripe\Control\HTTPRequest) object containing all request and environment information
|
||||||
|
Loading…
Reference in New Issue
Block a user