Adding WWW in Domain? - reactjs

my website hosted on ec2 - AWS. I want to add www in my website. Also my website has ssl. I am not able to add www in my website. I want my website full domain should be start with https://www.
I installed ubantu.

First, connect to your ec2 instance using ssh
After connect successfully go to your root directory using sudo su -
After that run sudo nano /etc/apache2/sites-available/000-default.conf to open your config file.
then in your vi editor you have to write below code
ServerName yourdomain.com
ServerAlias www.yourdomain.com
<Directory /var/www/html/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-Proto} =http
RewriteRule (.*) https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
save the file.
And restart your apache server using
service apache2 restart.
Hope this will help you.

Related

403 error through Apache2.4 Directory Alias: what's wrong?

I ask for some help to keep hairs on my head :D
More seriously, I tried a lot "solutions" found on different posts on different forums, without any result so I need a clean and fresh point of view...
So : I run a JEE application with Apache 2.4 and Tomcat 9 with mod_jk.
To avoid to store heavy content like video in my JEE webapp I created a directory on my server dedicated to some static content.
To do that I try to set a directory alias in my apache vhost, but I get 403 error.
You will find my vhost below, with an alias from /video to /etc/mondir/video (I tried with or without ending /)
I tried a lot of Directory directives without result
Apache2 owned the targeted directory trough www-data user
I also tried to declare the directory alias in etc/apache2/mods-available/alias.conf : not better.
I have no more idea and find no mode idea on the Internet.
Could you please give me some clue? help? advise?
Thank a lot !
<VirtualHost *:443>
ServerName mondomaine.com
ServerAlias www.mondomaine.com
ServerAdmin webmaster#localhost
#DocumentRoot /var/www
DocumentRoot /etc/mondir/
<Directory /etc/mondir/>
Options FollowSymLinks
AllowOverride None
</Directory>
#Add acces to static ressource in /etc/mondir
Alias "/video" "/etc/mondir/video"
Alias "/moncontext/video" "/etc/mondir/video"
<Directory "/etc/mondir/video">
#Options Indexes MultiViews FollowSymLinks
#AllowOverride None
#Order allow,deny
#Allow from all
#Options FollowSymlinks
#AllowOverride None
#Require all granted
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require local
</Directory>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.mondomaine\.com
RewriteRule ^video/(.*) /video/$1 [L,QSA]
RewriteRule ^video(.*) /video/$1 [L,QSA]
RewriteRule ^moncontext/(.*) /moncontext/$1 [L,QSA]
RewriteRule ^moncontext(.*) /moncontext/$1 [L,QSA]
RewriteRule ^(.*) /moncontext/$1 [L,QSA]
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/mondomaine.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/mondomaine.com/privkey.pem
JkMount /moncontext/* ajp13_worker
</VirtualHost>
The good directive is "Require all granted"
But, above all, the problem and the solution is on mod_rewrite side.
By default, the rewrite doesnt reach the filesystem, only URI.
Rewrite rule must have the Pass Through option (PT flag) to be seen by the Dir Alias.
More information on mod_rewrite documentation : it's written and simple if you know where to read.
Thank all,

Virtual host for angular 2 application in apache 2 not working

I need to create a virtual host or domain for my angular 2 application.
In brief, i had followed the below steps:
1) Created virtual host file for my site (From: https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-14-04-lts)
2) build the project in prod mode: ng build --prod (got dist folder)
These are my settings files from the above tutorial link that i had made in my server:
etc\apache2\sites-available\mydomain.com.conf
ServerName mydomain.com
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html/Angular2/path_to_my_app
<Directory /var/www/html/Angular2/path_to_my_app>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
</Directory>
In my windows host file added an entry to my site to map the ip
C:\Windows\System32\drivers\etc\hosts
10.*.*.* mydomain.com
In my server etc/host added an entry
etc\hosts
127.0.0.1 mydomain.com
In my angular 2 application's src folder (where index.html resides)
<IfModule mod_rewrite.c>
Options Indexes FollowSymLinks
RewriteEngine On
RewriteBase /var/www/html/Angular2/path_to_my_app
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>
And in the same folders index.html:
<base href="/var/www/html/Angular2/path_to_my_app">
My package.json has:
"start": "ng serve --host mydomain.com"
The created domain seems to load (hopefully, assuming deep links works), but when i hit mydomain.com, i get the angular2's folder structure view in my browser, not my site loaded
Where is my configuration incorrect.
Do i need to configure any other file in angular 2. If so which?
ServerName mydomain.com
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html/Angular2/path_to_my_app/src
in etc\apache2\sites-available\mydomain.com.conf, append /src to DocumentRoot

Error with apache virtual host configuration for symfony project

I created the project using Symfony framework, and when I am runing build in server in prod or dev env runs ok, But now I move project to debian server, install apache and create virtual host. It shows only directory list and not starts the app. I think that is something wrong with my virual host configuration. I am using Apache/2.4.10 (Debian) Server, PHP 5.6.19-0+deb8u1 (cli).
Here is the code for virtual host:
<VirtualHost *:80>
ServerName mose
ServerAlias 10.5.0.62
DocumentRoot /var/www/mose/web
<Directory /var/www/mose/web/>
AllowOverride None
Require all granted
Allow from All
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ app.php [QSA,L]
</IfModule>
</Directory>
# uncomment the following lines if you install assets as symlinks
# or run into problems when compiling LESS/Sass/CoffeScript assets
# <Directory /var/www/mose>
# Options FollowSymlinks
# </Directory>
# optionally disable the RewriteEngine for the asset directories
# which will allow apache to simply reply with a 404 when files are
# not found instead of passing the request into the full symfony stack
<Directory /var/www/mose/web/bundles>
<IfModule mod_rewrite.c>
RewriteEngine Off
</IfModule>
</Directory>
ErrorLog /var/log/apache2/project_error.log
CustomLog /var/log/apache2/project_access.log combined
</VirtualHost>
The right answer was AllowOverride All from Dawid Sajdak. Tnx for help

zend 2 not loading with apache on my computer

Trying to setup zend with apache on my latop running linux mint 16. I'm not sure what I could have missed in the setup, but when I navigate to localhost I just get a blank page.
Install apaache,php, enabled mod_rewrite:
apt-get install apache2
apt-get install php5
apt-get install libapache2-mod-php5
a2enmod rewrite
Copied my zend app (built with the skeleton) to /var/www/t1 (t1 is the app's folder)
Edited: /etc/apache2/sites-enabled/000-default.conf
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
DocumentRoot /var/www/t1/public
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/t1/public/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
RewriteEngine off
<Location />
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ /index.php [NC,L]
</Location>
LogLevel warn
</VirtualHost>
Restarted apache
service apache2 stop
service apache2 start
When I browse to http://localhost I just get a blank page.
edit: After turning on error reporting I found the error was:
Fatal error: Undefined class constant 'MYSQL_ATTR_INIT_COMMAND' in /var/www/t1/config/autoload/global.php on line 19
This was because I forgot to install the mysql module so after doing that it solved the issue.
sudo apt-get install php5-mysql
You probably need to add ini_set('display_errors', 1') and ini_set('error_reporting', E_ALL) at the top of your public/index.php, or do that in your php.ini. You are probably having an exception which is happening before ZF2 can catch it (setup related).
That will in first place allow you to see what the error is, and then it is usually trivial to fix it and move on.

how to run cakephp application on xampp

i am new to CakePHP, i have configured cakephp on Xampp it's working perfectly.
my folder structure is :
To make it run cakephp I have updated the document root directory(c:/xampp/hdocs/cakephp/app/webroot) in Http.conf which is located in apache conf folder
then i started apache cakephp framework worked out . browser shown a home page
i try to run Simple cakephp example application
c:/xampp/hdocs/polls/app/webroot
In the same manner i have configured cakephp example application on xampp and i have also updated the http.conf . But it's not working ,when i run the server simply showing blank page in browser .
thanks in advance
If you are using the path you provided above in your browser then you are just viewing that directory location in your browser.
You need to go through your local apache webserver by entering a local host url or any alias you may have setup.
http://localhost/<cakePHP app name>/<controller>/<action>/
if you want to go to the root cakephp app then it would be
http://localhost/<cakephp app name>/
Hope somebody finds it useful...
cakephp_3_x-x
xampp v 3.2.1
PART 1 (to test that cakePHP is working at all, using cakePHP included server)
Create the DB following the cakePHP tutor
In bake.bat -- add php path:
J:\xampp\php\php "%lib%cake.php" %*
DOS prompt:
J:\xampp\htdocs\cakephp-3-1-6>.\bin\cake bake all users
J:\xampp\htdocs\cakephp-3-1-6>.\bin\cake bake all bookmarks
J:\xampp\htdocs\cakephp-3-1-6>.\bin\cake bake all tags
cmd> cd J:\xampp\htdocs\cakephp-3-1-6
J:\xampp\htdocs\cakephp-3-1-6>set PATH=%PATH%;J:\xampp\php\;
J:\xampp\htdocs\cakephp-3-1-6>bin\cake server
to look at it http://localhost:8765/
PART 2 (for example, if we have port 8787 free to use for virtual host)
Repeat (for J:\xampp\apps\bookmarker)
In bake.bat -- add php path:
J:\xampp\php\php "%lib%cake.php" %*
DOS prompt:
J:\xampp\apps\bookmarker>.\bin\cake bake all users
J:\xampp\apps\bookmarker>.\bin\cake bake all bookmarks
J:\xampp\apps\bookmarker>.\bin\cake bake all tags
J:\xampp\htdocs\applications.html (create your own application section...:
<!-- START cakephp-3-0-0 bookmarker -->
<div align="center" class="module_table">
)
...
<div align="right" class="module_access"><a target="_blank" name="bookmarker" href="http://localhost:8787/bookmarks">Access</a></div>
...
1) main httpd.conf.
Listen 8787
<VirtualHost *:8787>
DocumentRoot "J:\xampp\apps\bookmarker"
# ServerName www.example.com
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory "J:\xampp\apps\bookmarker" >
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>
# Other directives here
</VirtualHost>
DO not include application specific config for apache:
# Include "J:/xampp/apps/bookmarker/conf/httpd-prefix.conf"
2) key: for css to work: in webroot/.htaccess
#<IfModule mod_rewrite.c>
# RewriteEngine On
# ## RewriteBase J:\xampp\apps\bookmarker\src\
# RewriteCond %{REQUEST_FILENAME} !-f
# RewriteRule ^ index.php [L]
#</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
The rest is as installed by cakePHP bake to try either through xampp application interface or directly:
http://localhost:8787/bookmarks

Resources