Skip to content

Commit

Permalink
Add original config file and subdomain parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
hinashiki committed May 5, 2016
1 parent 23e4468 commit e10671c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@
'Seo\\Query' => __DIR__.'/classes/query.php',
'Seo\\Pagination' => __DIR__.'/classes/pagination.php',
));
\Config::load('seo', true);
4 changes: 2 additions & 2 deletions classes/seo.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ public function check_redirect()
// check added www in production env
if(\Fuel\Core\Fuel::$env === \Fuel\Core\Fuel::PRODUCTION)
{
if( ! preg_match('/^www\./', $_SERVER['HTTP_HOST']))
if( ! preg_match('/^'.\Config::get('seo.subdomain').'\./', $_SERVER['HTTP_HOST']))
{
$new_uri = \Fuel\Core\Input::protocol().'://www.'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$new_uri = \Fuel\Core\Input::protocol().'://'.\Config::get('seo.subdomain').'.'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
\Fuel\Core\Response::redirect($new_uri, 'location', 301);
}
}
Expand Down
4 changes: 4 additions & 0 deletions config/seo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
return array(
'subdomain' => 'www',
);

0 comments on commit e10671c

Please sign in to comment.