Hello! Faced with the complexity of setting up .htaccess file. I have a symlink “current” in the root of the domain, which leads to the “web” yii folder of the project. But prettyUrl links do not work: with the enableStrictParsing option disabled, it always sends to the main page, and with the enabled, write a 404 error.
My urlManagerSettings in web config:
'urlManager'=>[
'class' => 'yii\web\UrlManager',
'enablePrettyUrl' => true,
'showScriptName' => false,
'baseUrl' => '',
'enableStrictParsing' => true,
'rules' => [
'<controller>/<action>' => '<controller>/<action>'
],
],
My .htaccess in domain folder (with “current” symlink that links to project/web):
<IfModule mod_autoindex.c>
Options -Indexes
</IfModule>
# Block access to "hidden" directories whose names begin with a period. This
# includes directories used by version control systems such as Subversion or Git.
<IfModule mod_rewrite.c>
RewriteCond %{SCRIPT_FILENAME} -d
RewriteCond %{SCRIPT_FILENAME} -f
RewriteRule "(^|/)\." - [F]
</IfModule>
# Block access to backup and source files
# These files may be left by some text/html editors and
# pose a great security danger, when someone can access them
<FilesMatch "(\.(bak|bat|config|sql|fla|md|psd|ini|log|sh|inc|swp|dist)|~|init|composer\.json|composer\.lock)$">
Order allow,deny
Deny from all
Satisfy All
</FilesMatch>
# Increase cookie security
<IfModule php5_module>
php_value session.cookie_httponly true
</IfModule>
# Settings to hide index.php and ensure pretty urls
RewriteEngine on
Options +FollowSymLinks
RewriteCond %{REQUEST_URI} !^/(current)
RewriteRule ^assets/(.*)$ /current/assets/$1 [L]
RewriteRule ^css/(.*)$ current/css/$1 [L]
RewriteRule ^js/(.*)$ current/js/$1 [L]
RewriteRule ^images/(.*)$ current/images/$1 [L]
RewriteRule (.*) current/$1
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php
My .htaccess in web folder
AddDefaultCharset UTF-8
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]
My access log content:
77.222.99.22 - - [04/Jan/2022:13:17:04 +0300] "GET /debug/default/toolbar?tag=61d41ea03796f HTTP/1.0" 404 33 "http://test-task.4business.online/site/about" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36 OPR/82.0.4227.50"
77.222.99.22 - - [04/Jan/2022:13:17:04 +0300] "GET /current/assets/4d6ae886/css/bootstrap.css.map HTTP/1.0" 200 514791 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36 OPR/82.0.4227.50"
77.222.99.22 - - [04/Jan/2022:13:17:04 +0300] "GET /current/assets/4d6ae886/js/bootstrap.bundle.js.map HTTP/1.0" 200 402657 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36 OPR/82.0.4227.50"
I would be grateful for your help