Webserver issues with domain!

New to Debian (Or Linux in general)? Ask your questions here!
Post Reply
Message
Author
EbskyMebsky
Posts: 2
Joined: 2017-11-27 13:00

Webserver issues with domain!

#1 Post by EbskyMebsky »

So I created my webserver and when I go to www.MyDebianWebserver.online it works fine.

However when I go to MyDebianWebserver.online I get a folder view with a folder of my webpage (MyDebianWebserver.online) which if I click then produces a url of MyDebianWebserver.online/MyDebianWebserver.online

The easiest solution I can think of is simply to redirect the MyDebianWebserver.online requests to www.MyDebianWebserver.online and voila that should solve it.

My problem here is I have been tinkering with the files under /etc/apache2/sites-available as well as the .htaccess file under the root folder of my phpbb project.

This is the file /etc/apache2/sites-available/MyDebianWebServer.online.conf

Code: Select all

<VirtualHost *:80>
    ServerName MyDebianWebserver.online
    ServerAlias www.MyDebianWebserver.online
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =MyDebianWebserver.online [OR]
RewriteCond %{SERVER_NAME} =www.MyDebianWebserver.online
#RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

RewriteCond %{HTTP_HOST} ^MyDebianWebserver.online$ [NC]
RewriteRule (.*) http://www.MyDebianWebserver.online/$1 [R=301,L] 

<Directory /var/www/html/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>


</VirtualHost>

And this is the .htaccess file under root folder of phpbb project

Code: Select all

<IfModule mod_rewrite.c>
RewriteEngine on

RewriteCond %{HTTP_HOST} ^MyDebianWebserver.online [NC]
RewriteRule ^(.*)$ http://www.MyDebianWebserver.online$1 [L,R=301,NC]

RewriteCond %{ENV:HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]

#
# Uncomment the statement below if URL rewriting doesn't
# work properly. If you installed phpBB in a subdirectory
# of your site, properly set the argument for the statement.
# e.g.: if your domain is test.com and you installed phpBB
# in http://www.test.com/phpBB/index.php you have to set
# the statement RewriteBase /phpBB/
#
RewriteBase /MyDebianWebserver.online

#
# Uncomment the statement below if you want to make use of
# HTTP authentication and it does not already work.
# This could be required if you are for example using PHP via Apache CGI.
#
#RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]

#
# The following 3 lines will rewrite URLs passed through the front controller
# to not require app.php in the actual URL. In other words, a controller is
# by default accessed at /app.php/my/controller, but can also be accessed at
# /my/controller
#
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ app.php [QSA,L]
#RewriteCond %{HTTP_HOST} ^.MyDebianWebserver.online$ [NC]
#RewriteRule ^(.*) https://www.MyDebianWebserver.online/$1 [L,R=301]
# If symbolic links are not already being followed,
# uncomment the line below.
# http://anothersysadmin.wordpress.com/2008/06/10/mod_rewrite-forbidden-403-with-apache-228/
#
#Options +FollowSymLinks
</IfModule>

# Apache content negotation tries to interpret non-existent paths as files if
# MultiViews is enabled. This will however cause issues with paths containg
# dots, e.g. for the cron tasks
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>

# With Apache 2.4 the "Order, Deny" syntax has been deprecated and moved from
# module mod_authz_host to a new module called mod_access_compat (which may be
# disabled) and a new "Require" syntax has been introduced to mod_authz_host.
# We could just conditionally provide both versions, but unfortunately Apache
# does not explicitly tell us its version if the module mod_version is not
# available. In this case, we check for the availability of module
# mod_authz_core (which should be on 2.4 or higher only) as a best guess.
<IfModule mod_version.c>
<IfVersion < 2.4>
<Files "config.php">
Order Allow,Deny
Deny from All
</Files>
<Files "common.php">
Order Allow,Deny
Deny from All
</Files>
</IfVersion>
<IfVersion >= 2.4>
<Files "config.php">
Require all denied
</Files>
<Files "common.php">
Require all denied
</Files>
</IfVersion>
</IfModule>
<IfModule !mod_version.c>
<IfModule !mod_authz_core.c>
<Files "config.php">
Order Allow,Deny
Deny from All
</Files>
<Files "common.php">
Order Allow,Deny
Deny from All
</Files>
</IfModule>
<IfModule mod_authz_core.c>
<Files "config.php">
Require all denied
</Files>
<Files "common.php">
Require all denied
</Files>
</IfModule>
</IfModule>
As far as I understand the code below should redirect MyDebianServer.online requests to www.MyDebianServer.online

Code: Select all

RewriteCond %{SERVER_NAME} =MyDebianWebserver.online [OR]
RewriteCond %{SERVER_NAME} =www.MyDebianWebserver.online
#RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
so why isnt it?

Post Reply