Hello Friends,
I got success to remove web part from URL with help of "
Aaron Francis" tutorial.
http://aaronfrancis.com/blog/2014/1/9/hosting-an-advanced-yii2-application-on-heroku
using this tutorial i customize for my basic application of yii2, it work near fine but some file not include or occur "404: file not found" error in console.
so, my .htaccess is
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
</IfModule>
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_URI} ^/(assets|css|images|js|fonts)
RewriteRule ^/assets/$ /web/assets/$1 [L]
RewriteRule ^css/(.*)$ web/css/$1 [L]
RewriteRule ^images/(.*)$ web/images/$1 [L]
RewriteRule ^js/(.*)$ web/js/$1 [L]
RewriteRule ^fonts/(.*)$ web/fonts/$1 [L]
RewriteRule ^assets/(.*)$ assets/$ [L]
RewriteCond %{REQUEST_URI} !^/web/(assets|css|images|js|fonts)/
RewriteCond %{REQUEST_URI} !index.php
RewriteCond %{REQUEST_URI} ^/
RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ web/index.php
</IfModule>
my web.php file:
'components' => [
'request' => [
'class' => 'app\components\Request',
'web'=> '/web',
'cookieValidationKey' => 'secure',
],
]
my component file:
<?php
namespace app\components;
class Request extends \yii\web\Request {
public $web;
public $adminUrl;
public function getBaseUrl(){
return str_replace($this->web, "", parent::getBaseUrl()) . $this->adminUrl;
}
/*
If you don't have this function, the admin site will 404 if you leave off
the trailing slash.
E.g.:
Would work:
site.com/web/site/login to site.com/site/login
Using this function, both will work.
*/
public function resolvePathInfo(){
if($this->getUrl() === $this->adminUrl){
return "";
}else{
return parent::resolvePathInfo();
}
}
}
?>
and at last i attached the error log file.
6197
Plaese help me…
Thanks in Advance…