-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Open
Labels
status:ready for adoptionFeel free to implement this issue.Feel free to implement this issue.type:docsDocumentationDocumentation
Description
This is related to #316.
Two proposals below.
The proposals are not strongly tested and are for Apache only (I'm not expert in nginx).
If you are interested, I can test them better, fork and propose formally. Apache only.
Regards,
HUjuice
If you have per directory permissions only (.htaccess):
# use mod_rewrite for pretty URL support
RewriteEngine On
# Backend requests
RewriteCond %{REQUEST_URI} ^/admin$ [OR]
RewriteCond %{REQUEST_URI} ^/admin/
# If a directory or a file exists, use the request directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward the request to admin/index.php
RewriteRule . admin/index.php
# Frontend requests
RewriteCond %{REQUEST_URI} !^/admin$
RewriteCond %{REQUEST_URI} !^/admin/
# If a directory or a file exists, use the request directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward the request to index.php
RewriteRule . index.php
# if $showScriptName is false in UrlManager, do not allow accessing URLs with script name
RewriteRule ^(admin/)?index.php/ - [L,R=404]
# ...other settings...
Options -Indexes +FollowSymLinks
AllowOverride None
Require all granted
If you can write a complete VirtualHost configuration and want to keep separate web directory:
<VirtualHost *:80>
ServerName app.example.com
# Frontend
# ==============================
DocumentRoot /path/to/yii2-advanced/frontend/web
<Directory /path/to/yii2-advanced/frontend/web>
# Use mod_rewrite for pretty URL support
RewriteEngine On
# If a directory or a file exists, use the request directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward the request to index.php
RewriteRule . index.php
# If $showScriptName is false in UrlManager, do not allow accessing URLs with script name
RewriteRule ^index.php/ - [L,R=404]
# ...other settings...
Options -Indexes +FollowSymLinks
AllowOverride None
Require all granted
</Directory>
# Backend
# ==============================
Alias /admin /path/to/yii2-advanced/backend/web
<Directory /path/to/yii2-advanced/backend/web>
# Use mod_rewrite for pretty URL support
RewriteEngine On
# If a directory or a file exists, use the request directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward the request to index.php
RewriteRule . index.php
# If $showScriptName is false in UrlManager, do not allow accessing URLs with script name
RewriteRule ^index.php/ - [L,R=404]
# ...other settings...
Options -Indexes +FollowSymLinks
AllowOverride None
Require all granted
</Directory>
</VirtualHost>
Note: sorry, but the external configuration linked at the end of the document is an overkill and in contrast with the Apache recommendations. I filed a bug to Oleg about: mickgeek/yii2-advanced-one-domain-config#16
PrplHaz4mickgeek
Metadata
Metadata
Assignees
Labels
status:ready for adoptionFeel free to implement this issue.Feel free to implement this issue.type:docsDocumentationDocumentation