Yii2 cannot reach the backend part - yii2-advanced-app

I really don't get it how can i get to that backend .. How i installed the advanced template is like the way they show it in the official site : http://www.yiiframework.com/download/ . Everything step by step. When i try frontend.dev (in my case eshop) i am redirected to the front end part but when i try backend.dev(in my case eshop/admin) i am also redirected to the frontend.
This is my host file:
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
# 127.0.0.1 modules
127.0.0.1 eshop
127.0.0.1 eshop/admin
0.0.0.1 mssplus.mcafee.com
And the vhost.conf:
<VirtualHost *:80>
ServerName eshop
DocumentRoot "C:/xampp/htdocs/eshop/frontend/web/"
<Directory "C:/xampp/htdocs/eshop/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
# use index.php as index file
DirectoryIndex index.php
# ...other settings...
# Apache 2.4
Require all granted
## Apache 2.2
# Order allow,deny
# Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName eshop/admin
DocumentRoot "C:/xampp/htdocs/eshop/backend/web/"
<Directory "C:/xampp/htdocs/eshop/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
# use index.php as index file
DirectoryIndex index.php
# ...other settings...
# Apache 2.4
Require all granted
## Apache 2.2
# Order allow,deny
# Allow from all
</Directory>
</VirtualHost>
Where is my mistake ? A lot of thanks in advance!

Using a slash (/) in hostname is illegal, as it is defined in RFC 952. Therefore in the URL "http://eshop/admin" the server name is "eshop" and apache is using of course your first virtual server setting.
Summarized, your idea will never work. You should use eshop-admin as server name.

Related

.htaccess redirection except specific paths

I am using opencart on a Godaddy hosting with cpanel. I am using a .htaccess file to do the following with no success.
I am trying to redirect everything from "http://northfalcons.com" or "http://www.northfalcons.com" to “https://northfalcons.com”.
But following three pages:
1.https://northfalcons.com/index.php?route=product/category&path=60
2.https://northfalcons.com/index.php?route=product/category&path=61
3.https://northfalcons.com/index.php?route=product/category&path=62
Need to be redirected to http instead of https, like follows:
1.http://northfalcons.com/index.php?route=product/category&path=60
2.http://northfalcons.com/index.php?route=product/category&path=61
3.http://northfalcons.com/index.php?route=product/category&path=62
How do I do this? Please help!
First You can Backup Your .htaccess files:
After Replace Following .htaccess code in Your Root .htaccess file:
# 1.To use URL Alias you need to be running apache with mod_rewrite enabled.
# 2. In your opencart directory rename htaccess.txt to .htaccess.
# For any support issues please visit: http://www.opencart.com
Options +FollowSymlinks
# Prevent Directoy listing
Options -Indexes
# Prevent Direct Access to files
<FilesMatch "(?i)((\.tpl|\.ini|\.log|(?<!robots)\.txt))">
Order deny,allow
Deny from all
</FilesMatch>
# SEO URL Settings
RewriteEngine On
# If your opencart installation does not run on the main web folder make sure you folder it does run in ie. / becomes /shop/
RewriteBase /
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteRule ^download/(.*) /index.php?route=error/not_found [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
RewriteCond %{QUERY_STRING} ^route=common/home$
RewriteRule ^index\.php$ https://www.northfalcons.com? [R=301,L]
### Additional Settings that may need to be enabled for some servers
### Uncomment the commands by removing the # sign in front of it.
### If you get an "Internal Server Error 500" after enabling any of the following settings, restore the # as this means your host doesn't allow that.
# 1. If your cart only allows you to add one item at a time, it is possible register_globals is on. This may work to disable it:
# php_flag register_globals off
# 2. If your cart has magic quotes enabled, This may work to disable it:
# php_flag magic_quotes_gpc Off
# 3. Set max upload file size. Most hosts will limit this and not allow it to be overridden but you can try
# php_value upload_max_filesize 999M
# 4. set max post size. uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value post_max_size 999M
# 5. set max time script can take. uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value max_execution_time 200
# 6. set max time for input to be recieved. Uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value max_input_time 200
# 7. disable open_basedir limitations
# php_admin_value open_basedir none
I hope it's 100% working for you.
Thanks for asking...

apache2: how to find out why I get a 403 error?

That is from the apache error_log:
[Mon Oct 17 17:55:42 2011] [error] [client 127.0.0.1] (13)Permission denied: access to /index.html denied
In /etc/apache2/vhosts.d I've created this file:
<VirtualHost 127.0.0.1:3000>
DocumentRoot "/home/mm/lib/vokabeltrainer"
ServerName localhost:3000
<Directory "/home/mm/lib/vokabeltrainer">
Options FollowSymLinks ExecCGI
AddHandler cgi-script .pl
IndexIgnore *
RewriteEngine on
RewriteCond %{DOCUMENT_ROOT}/public/%{REQUEST_URI} -f
RewriteRule ^(.*) public/$1 [L]
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI} !-f
RewriteRule ^(.*) vokabeltrainer.pl [L]
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
The /etc/apache2/listen.conf looks like this:
Listen 127.0.0.1:3000
NameVirtualHost 127.0.0.1:3000
For testing, I've modified the folder like chmod -R 0777 /home/mm/lib/vokabeltrainer
When I run the vokabeltrainer.pl (Mojolicious::Lite script) with morbo development server it works.
Has somebody a clue where I should look?
As Ikegami pointed out, my first problem was that I didn't consider the /home/mm/lib part of the path: the lib-directory didn't have enough rights so I had to ad the needed rights.
Then I changed the path in the shebang form /usr/local/bin/perl to /usr/bin/perl and installed Mojolicious::Lite for the /usr/bin/perl.
The last thing I had to do, was writing the url like this http://localhost:3000/vokabeltrainer.pl/random instead of http://localhost:3000/random.
(In the Pretty "Web 2.0" URLs at mojo/wiki/Apache-deployment is shown a way to keep the short url)

Apache virtual host on a specific directory

I need my site to have a virtual host on a specific directory for my zend application. When user enters www.example.com it should go to normal document root but when user navigates to www.example.com/cms it should go to /var/www/cms/public which its .htaccess file is like this:
SetEnv APPLICATION_ENV development
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
On localhost I added this lines to /etc/apache/httpd-vhosts.conf:
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "/var/www/cms/public"
ServerName persian_literature
# This should be omitted in the production environment
SetEnv APPLICATION_ENV development
<Directory "/var/www/cms/public">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Now http://localhost/ goes to /var/www/cms/public and every thing works. My question is how should I change change above code, to force http://localhost/ to be the normal directory root (so I could use other applications) and http://localhost/cms to be the virtual host?
A virtual host is done at the hostname/domainname level, not at a directory level. You can use an alias to point the URI /cms to some other directory on your server by putting
Alias /cms /var/www/cms/public
in a .conf file (this will not work in .htaccess)
Maybe a symlink (symbolic link)? You still should have the entry of course. And you'll have to put in the config (vhost config I think, maybe .htaccess) that apache should follow the symlink.

How to install Symfony framework on shared hosting account?

I have a questions while install Symfony framework on my shared hosting account.(hostmonster)
I can access SSH now, but I can not access httpd file.
so, I do not know how to set below setting using command line.
**
<Directory "/$data_dir/symfony/web/sf">
AllowOverride All
Allow from All
</Directory>
<VirtualHost *:80>
ServerName myapp.example.com
DocumentRoot "/home/steve/myproject/web"
DirectoryIndex index.php
Alias /sf /$data_dir/symfony/web/sf
<Directory "/home/steve/myproject/web">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
**
,
I tried this,
**
chmod 777 /home1/myaccount/php/data/symfony/web
chmod 777 /home1/myaccount/public_html/symfony/web
**
But nothing changed.
when access mydomain.com, it show like this
#!/usr/bin/env php
<?php
/*
* This file is part of the symfony package.
* (c) Fabien Potencier <fabien.potencier#symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
chdir(dirname(__FILE__));
require_once(dirname(__FILE__).'/config/ProjectConfiguration.class.php');
include(sfCoreAutoload::getInstance()->getBaseDir().'/command/cli.php');
Please advice me how should I do .?
Thanks!
You need to enable mod_rewrite on your apache instance. If you cannot access the httpd configuration file, then you should create a .htaccess file in your web root.
Here is an example .htaccess file typical with symfony installs:
Options +FollowSymLinks +ExecCGI
<IfModule mod_rewrite.c>
RewriteEngine On
# uncomment the following line, if you are having trouble
# getting no_script_name to work
#RewriteBase /
# we skip all files with .something
#RewriteCond %{REQUEST_URI} \..+$
#RewriteCond %{REQUEST_URI} !\.html$
#RewriteRule .* - [L]
# we check if the .html version is here (caching)
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
# no, so we redirect to our front web controller
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
If you are seeing
#!/usr/bin/env php
<?php
/*
* This file is part of the symfony package.
* (c) Fabien Potencier <fabien.potencier#symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
chdir(dirname(__FILE__));
require_once(dirname(__FILE__).'/config/ProjectConfiguration.class.php');
include(sfCoreAutoload::getInstance()->getBaseDir().'/command/cli.php');
when you head to yourdomain.com, you simply do not have PHP enabled. You may not even have it installed. A quick check is to create a file called info.php and put the following as it's contents
<?php phpinfo(); ?>
Upload info.php and navigate to yourdomain.com/info.php. If you are seeing the code you just entered you do not have php installed or enabled on your server. If you see a massive list of configuration items than I'm wrong.

Zend Framework Changing SetEnv APPLICATION_ENV to "production" causes apache 500 error

When I change APPLICATION_ENV to "production" and restart apache I get a 500 error. When it's set to development I have no problems. I'm completely miffed. Any suggestions? Config files are below
httpd-vhosts.conf
#
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.2/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
NameVirtualHost *:443
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
<VirtualHost *:443>
SSLEngine On
SSLCertificateFile "C:\Program Files\Zend\Apache2\conf\ssl\star.crt"
SSLCertificateKeyFile "C:\Program Files\Zend\Apache2\conf\ssl\star.key"
ServerAdmin postmaster#dummy-host.localhost
DocumentRoot "C:\Sidekick\public"
ServerName *
ServerAlias *
<Directory "C:\Sidekick\public">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
SetEnv APPLICATION_ENV development
</Directory>
ErrorLog "logs/dummy-host.localhost-error.log"
CustomLog "logs/dummy-host.localhost-access.log" combined
</VirtualHost>
.htaccess:
RewriteEngine On
RewriteCond %{REQUEST_METHOD} GET
RewriteCond %{DOCUMENT_ROOT}/cached/index.html -f
RewriteRule ^/*$ cached/index.html [L]
RewriteCond %{REQUEST_METHOD} GET
RewriteCond %{DOCUMENT_ROOT}/cached/%{REQUEST_URI}\.html -f
RewriteRule .* cached/%{REQUEST_URI}\.html [L]
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
index.php
<?php
// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
// Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
get_include_path(),
)));
/** Zend_Application */
require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
$application->bootstrap()
->run();
That code looks OK to me - and it would be working for a non-'production' environment, I'd assume.
I would look in configs/application.ini to make sure you had a [production] section, with or without the ': extends]' part. Also, wrap the bootstrap()->run(); in a try/catch, and have the exception generated, and displayed. at least till you've debugged this.