Domain redirected to frontend/web - yii2

When I access http://alpha.myweb.com/ it redirected to http://alpha.myweb.com/frontend/web/
It resulting website show without any asset.
Here is my vhost config
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster#localhost
ServerName alpha.myweb.com
ServerAlias www.alpha.myweb.com
DocumentRoot /var/www/html/myweb
#Options +FollowSymlinks
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
Here is my .htaccess
# prevent directory listings Options -Indexes IndexIgnore */*
# follow symbolic links Options FollowSymlinks RewriteEngine on RewriteRule ^administrator(/.+)?$ backend/web/$1 [L,PT] RewriteRule ^(.+)?$ frontend/web/$1
RewriteCond %{HTTP_HOST} ^alpha\.myweb\.com [NC] RewriteRule ^(.*)$ https://alpha.myweb.com/$1 [L,R=301]
What's wrong with my configuration? do I need to store frontend/config/main.php, backend/config/main.php and common\config\main.php
Thanks in advance?

Your apache document root should be /var/www/html/myweb/frontend/web and not /var/www/html/myweb which is your project root.

Related

How to use SSL HTML and Websockets on Apache?

I have only used Apache HTML on my backend and implemented my app using HTML/PHP requests so far. Now I want to implement a socket connection. For this, I am currently trying to set up the socket module on my Apache web server. I tried these steps. Reverse Proxy. However, after adding ProxyPass on the VirtualHost :443, I can no longer access my HTML pages.
503 Service Unavailable - The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.
Is it possible to still access the HTML/PHP pages despite the socket module? Do i have to create a new VirtualHost with a different Port, e.g. the Websocket Port but how can i make the handshake?
My apache2/sites-available/conf looks like this:
<VirtualHost *:80>
ServerName ***
<IfModule mod_ssl.c>
Redirect / https://***
</IfModule>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/***
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName ***
ServerAdmin webmaster#localhost
DocumentRoot /var/www/***
<Directory /var/www>
# Options -Indexes +FollowSymLinks
# AllowOverride none
# Order allow,deny
# allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond ${HTTP:Upgrade} websocket [NC]
RewriteCond ${HTTP:Connection} upgrade [NC]
RewriteRule .* "wss:/localhost:12123/$1" [P,L]
ProxyPass / https://localhost:12123/ #Here is the problem
ProxyPassReverse / https://localhost:12123/
ProxyRequests off
SSLEngine On
SSLCertificateFile /etc/letsencrypt/live/***/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/***/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/***/chain.pem
</VirtualHost>
</IfModule>

apache2 not opening index.html (404 Not Found)

I had several virtualhosts running with wordpress before. I uninstalled Wordpress to use my own website (HTML and CSS) but now I get an error "404 not found" saying "Not Found -
The requested URL was not found on this server." Can someone tell my why it is not opening the index.html file or where the problem could be found?
Here is my VirtualHost:
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin jw.webmaster#domain.com
DocumentRoot /var/www/domain.com/public
ServerName domain.com
ServerAlias domain.com
DirectoryIndex index.html
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/domaincom_error.log
CustomLog ${APACHE_LOG_DIR}/domaincom_access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

Site loading on port 443 and not on 80

I have site which isn't really working properly on SSL certificate.
The website works properly on 443 port with SSLEngine off directive in my configuration file, with SSLEngine on is responsing with 503 Error.
It also connects on port 80 by default and I don't really know where to change that because everywhere I have set port 443.
.htaccess file:
RewriteEngine On
RewriteCond %{SERVER_PORT} 443
RewriteRule ^(.*)$ https://www.antoszbk.xyz/$1 [R,L]
configuration file (while working properly):
<VirtualHost *:443>
ServerAdmin xxx#xxx.com
DocumentRoot /var/www/html/index.html
ServerName antoszbk.xyz
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# SSL Engine Switch:
# Enable/Disable SSL for this virtual host.
SSLEngine off
SSLCertificateFile /etc/ssl/certs/www.antoszbk.xyz.csr
SSLCertificateKeyFile /etc/ssl/private/www.antoszbk.xyz.key
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars
</Directory>
BrowserMatch "MSIE [2-6]" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
# MSIE 7 and newer should be able to use keepalive
BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
</VirtualHost>
The solution was in DNS Server Configuration.
Certificate given to me by provider was set to antoszbk.xyz alias but in my SSL configuration I set it up to www.antoszbk.xyz. Still receive an error if trying to connect by IPv6 (AAAA record) redirection but it is a matter of time for the DNS to process it.

Yii2 non https and www url redirected to frontend/web

I facing strange issue regarding URL in Yii2
When I visit myweb.com, www.myweb.com, http://myweb.com, https://myweb.com I got redirected to https://www.myweb.com/frontend/web and it show me 404 error.
But when I access https://www.myweb.com it work correctly no error shown.
Please help me to fix this issue, I think this is because virtualhost or .htaccess configuration here is my virtualhost
port 80 non https /etc/apache2/sites-available/myweb.com.conf
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster#localhost
ServerName myweb.com
ServerAlias www.myweb.com
DocumentRoot /var/www/html/myweb/frontend/web
Redirect / https://myweb.com/
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
and here is virtualhost https /etc/apache2/sites-available/http-myweb.com.conf
Listen 443
<VirtualHost *:443>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster#localhost
ServerName myweb.com
ServerAlias www.myweb.com
DocumentRoot /var/www/html/myweb/frontend/web
SSLEngine On
SSLCertificateFile "/home/jun/certificate.crt"
SSLCertificateKeyFile "/home/jun/private.key"
SSLCACertificateFile "/home/jun/ca_bundle.crt"
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
Here is .htaccess in project folder
# prevent directory listings
Options -Indexes
IndexIgnore */*
# follow symbolic links
Options FollowSymlinks
RewriteEngine on
RewriteRule ^administrator(/.+)?$ backend/web/$1 [L,PT]
RewriteRule ^(.+)?$ frontend/web/$1
RewriteCond %{HTTP_HOST} ^myweb\.com [NC]
RewriteRule ^(.*)$ https://www.myweb.com/$1 [L,R=301]
and here is .htaccess in frontend/web
RewriteEngine on
# RewriteBase /frontend/web
# 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
Here what I get from inspect element
General
Request URL:http://myweb.com/
Request Method:GET
Status Code:301 Moved Permanently (from disk cache)
Remote Address:123.231.250.140:80
Referrer Policy:no-referrer-when-downgrade
Response Headers
Content-Length:243
Content-Type:text/html; charset=iso-8859-1
Date:Mon, 17 Apr 2017 08:47:29 GMT
Location:https://www.myweb.com/frontend/web/
Server:Apache
So what's wrong with my code or configuration?
thanks in advance.

Apache2 webserver ubuntu 16.04 not allowing any page besides index.html

I'm attempting to add multiple html pages to my website.
I've pasted the files into /var/www/html which is what my virtual hosts file is pointing to. However, whenever I try to navigate to another html page such as domain.com/page.html it fails to find anything.
I feel like I'm missing a setting or something with apache2 that is preventing me from accessing anything but the index.html. I've checked to insure the files are in the correct directory. I hope someone has some idea whats going on as I'm a bit lost.
heres the virtual host file;
<VirtualHost 72.222.165.39:7777>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly
ServerName www.birnbaumdesign.com
ServerAlias *.birnbaumdesign.com
ServerAdmin royce.birnbaum#gmail.com
DocumentRoot /var/www/html
<Directory /var/www/html>
Options FollowSymLinks
AllowOverride None
Require all granted
</Directory>
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet