Apache working fine, except for 127.0.0.1 - apache

Everything was working fine, until I detected a bug,
My server cannot access his own services on 127.0.0.1.
I'm not sure if related but when I type 127.0.0.1 in Internet Explorer, it waits, then says www.127.0.0.1 is not reachable. I did add 'www.' forced recently, but now I changed this script to 'xxx.' instead of 'www.' and it still redirects me to www.127.0.0.1, the rest of my website gets redirected to 'xxx.'
This is httpd.conf:
# 'Main' server configuration
#
# The directives in this section set up the values used by the 'main'
# server, which responds to any requests that aren't handled by a
# <VirtualHost> definition. These values also provide defaults for
# any <VirtualHost> containers you may define later in the file.
#
# All of these directives may appear inside <VirtualHost> containers,
# in which case these default settings will be overridden for the
# virtual host being defined.
#
#
# ServerAdmin: Your address, where problems with the server should be
# e-mailed. This address appears on some server-generated pages, such
# as error documents. e.g. admin#your-domain.com
#
ServerAdmin admin#your-domain.com
#
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
#ServerName www.example.net
ServerName 127.0.0.1
#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
#DocumentRoot "c:/htdocs"
DocumentRoot "c:/htdocs"
#
# Each directory to which Apache has access can be configured with respect
# to which services and features are allowed and/or disabled in that
# directory (and its subdirectories).
#
# First, we configure the "default" to be a very restrictive set of
# features.
#
<Directory />
Options FollowSymLinks
AllowOverride none
Order deny,allow
Deny from all
</Directory>
#
# Note that from this point forward you must specifically allow
# particular features to be enabled - so if something's not working as
# you might expect, make sure that you have specifically enabled it
# below.
#
#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "c:/htdocs">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride All
#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all
</Directory>
This is httpd-vhost.conf:
<VirtualHost 127.0.0.1:80>
DocumentRoot c:/htdocs
ServerName 127.0.0.1
ServerAlias www.127.0.0.1 localhost www.localhost
ErrorLog logs/example-intern-error.txt
CustomLog logs/example-intern-access.txt common
</VirtualHost>
<VirtualHost *:80>
DocumentRoot c:/htdocs
ServerName sa-arp.net
ServerAlias www.example.net www.example.com example.com
ErrorLog logs/example-error.txt
CustomLog logs/example-access.txt common
RewriteEngine On
RewriteCond %{HTTP_HOST} !^xxx\. [NC]
RewriteRule ^(.*)$ http://xxx.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</VirtualHost>
I tried all combination possible, nothing seems to work.
Please help me I am out of resources and patiente!
Thank you,
rt-2

The answer was easy, the problem WAS Internet Explorer,
I used it because I was on the server itself testing the service and didn't want to install a new program.
Well Firefox did the job and worked, problem was the testing method.
rt-2
EDIT: The problem was not internet explorer, the problem was that I created a 301 redirection, which means the browser remembered the first thing I told him and then all my tests were futile for every domain I already tested once. (Yeah, that was frustrating). I updated this post just in case someone had a similar code and my issue.

Related

Apache server has bad interpretation incoming inquiries according to irrelevant domain names hosted on a single IP address

There is an Ubuntu server with LAMP stack.
There are hosted some quantity of sites on a single IP address.
IP address "white" and there are no any problems with access to server. Server stands for NAT with forwarded ports.
The situation is: there are some domains hosted on the server with a single IP address, for example domain1, domain2 and domain3. In the act of irrelevant inquiries to the server, for example to domain3 as domain3/123 or subdomain.domain3 (the directory 123 and subdomain has no exist) or direct inquiry on IP address, the server will forward this inquiry to the first domain (domain1) in the list.
How can I change it? I need next action: within irrelevant inquiries, the response has to be from the domain which has been requested. Another way, if there are no such directories, server has to returned answer about not existing requested site or had ignoring those requests.
In present time is realized the next scheme: there are on the server has been created a directory with name domain0 and was launched the virtual server for it and were uploaded custom pages with errors 403 and 404. If an irrelevant inquiry to any non-existing domain names has come, then Apache server will forward this inquiry to the first directory in the list to domain0 and then the user will get the page with error code.
So, I forced to ask my question to Stack Overflow community to help me with that issue. How do I can to implement Apache server settings for correct interpretation of incoming inquiries?
Thanks in advance!
Apache configuration:
# This is the main Apache server configuration file. It contains the
# configuration directives that give the server its instructions.
# See http://httpd.apache.org/docs/2.4/ for detailed information about
# the directives and /usr/share/doc/apache2/README.Debian about Debian specific
# hints.
#
#
# Summary of how the Apache 2 configuration works in Debian:
# The Apache 2 web server configuration in Debian is quite different to
# upstream's suggested way to configure the web server. This is because Debian's
# default Apache2 installation attempts to make adding and removing modules,
# virtual hosts, and extra configuration directives as flexible as possible, in
# order to make automating the changes and administering the server as easy as
# possible.
# It is split into several files forming the configuration hierarchy outlined
# below, all located in the /etc/apache2/ directory:
#
# /etc/apache2/
# |-- apache2.conf
# | `-- ports.conf
# |-- mods-enabled
# | |-- *.load
# | `-- *.conf
# |-- conf-enabled
# | `-- *.conf
# `-- sites-enabled
# `-- *.conf
#
#
# * apache2.conf is the main configuration file (this file). It puts the pieces
# together by including all remaining configuration files when starting up the
# web server.
#
# * ports.conf is always included from the main configuration file. It is
# supposed to determine listening ports for incoming connections which can be
# customized anytime.
#
# * Configuration files in the mods-enabled/, conf-enabled/ and sites-enabled/
# directories contain particular configuration snippets which manage modules,
# global configuration fragments, or virtual host configurations,
# respectively.
#
# They are activated by symlinking available configuration files from their
# respective *-available/ counterparts. These should be managed by using our
# helpers a2enmod/a2dismod, a2ensite/a2dissite and a2enconf/a2disconf. See
# their respective man pages for detailed information.
#
# * The binary is called apache2. Due to the use of environment variables, in
# the default configuration, apache2 needs to be started/stopped with
# /etc/init.d/apache2 or apache2ctl. Calling /usr/bin/apache2 directly will not
# work with the default configuration.
ServerSignature Off
ServerTokens Prod
# Global configuration
#
#
# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
#
# NOTE! If you intend to place this on an NFS (or otherwise network)
# mounted filesystem then please read the Mutex documentation (available
# at <URL:http://httpd.apache.org/docs/2.4/mod/core.html#mutex>);
# you will save yourself a lot of trouble.
#
# Do NOT add a slash at the end of the directory path.
#
#ServerRoot "/etc/apache2"
#
# The accept serialization lock file MUST BE STORED ON A LOCAL DISK.
#
#Mutex file:${APACHE_LOCK_DIR} default
#
# The directory where shm and other runtime files will be stored.
#
DefaultRuntimeDir ${APACHE_RUN_DIR}
#
# PidFile: The file in which the server should record its process
# identification number when it starts.
# This needs to be set in /etc/apache2/envvars
#
PidFile ${APACHE_PID_FILE}
#
# Timeout: The number of seconds before receives and sends time out.
#
Timeout 300
#
# KeepAlive: Whether or not to allow persistent connections (more than
# one request per connection). Set to "Off" to deactivate.
#
KeepAlive On
#
# MaxKeepAliveRequests: The maximum number of requests to allow
# during a persistent connection. Set to 0 to allow an unlimited amount.
# We recommend you leave this number high, for maximum performance.
#
MaxKeepAliveRequests 100
#
# KeepAliveTimeout: Number of seconds to wait for the next request from the
# same client on the same connection.
#
KeepAliveTimeout 5
# These need to be set in /etc/apache2/envvars
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
#
# HostnameLookups: Log the names of clients or just their IP addresses
# e.g., www.apache.org (on) or 204.62.129.132 (off).
# The default is off because it'd be overall better for the net if people
# had to knowingly turn this feature on, since enabling it means that
# each client request will result in AT LEAST one lookup request to the
# nameserver.
#
HostnameLookups Off
# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# logged here. If you *do* define an error logfile for a <VirtualHost>
# container, that host's errors will be logged there and not here.
#
ErrorLog ${APACHE_LOG_DIR}/error.log
#
# LogLevel: Control the severity of messages logged to the error_log.
# Available values: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the log level for particular modules, e.g.
# "LogLevel info ssl:warn"
#
LogLevel warn
# Include module configuration:
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf
# Include list of ports to listen on
Include ports.conf
# Sets the default security model of the Apache2 HTTPD server. It does
# not allow access to the root filesystem outside of /usr/share and /var/www.
# The former is used by web applications packaged in Debian,
# the latter may be used for local directories served by the web server. If
# your system is serving content from a sub-directory in /srv you must allow
# access here, or in any related virtual host.
<Directory />
Options FollowSymLinks
AllowOverride none
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/>
Options -Indexes
AllowOverride All
Require all granted
</Directory>
#<Directory /srv/>
# Options Indexes FollowSymLinks
# AllowOverride None
# Require all granted
#</Directory>
# AccessFileName: The name of the file to look for in each directory
# for additional configuration directives. See also the AllowOverride
# directive.
#
AccessFileName .htaccess
#
# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
#
<FilesMatch "^\.ht">
Require all denied
</FilesMatch>
#
# The following directives define some format nicknames for use with
# a CustomLog directive.
#
# These deviate from the Common Log Format definitions in that they use %O
# (the actual bytes sent including headers) instead of %b (the size of the
# requested file), because the latter makes it impossible to detect partial
# requests.
#
# Note that the use of %{X-Forwarded-For}i instead of %h is not recommended.
# Use mod_remoteip instead.
#
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
# Include of directories ignores editors' and dpkg's backup files,
# see README.Debian for details.
# Include generic snippets of statements
IncludeOptional conf-enabled/*.conf
# Include the virtual host configurations:
IncludeOptional sites-enabled/*.conf
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
Virtual Hosts configuration (identical for all VH):
<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 domen3.name
ServerAlias www.domen3.name
ServerAdmin webmaster#localhost
DocumentRoot /var/www/domen3.name
# 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
RewriteEngine on
RewriteCond %{SERVER_NAME} =domen3.name
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
<VirtualHost *:443>
Protocols h2 http/1.1
<IfModule mod_headers.c>
Header always set Strict-Transport-Security "max-age=63072000; includeSubDomains; preload"
</IfModule>
<IfModule mod_ssl.c>
# 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 domen3.name
ServerAlias www.domen3.name
ServerAdmin webmaster#localhost
DocumentRoot /var/www/domen3.name
# 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
SSLCertificateFile /etc/letsencrypt/live/domen3.name/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/domen3.name/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</IfModule>
</VirtualHost>
You have multiple possible scenarios (since your question is not super clear to me).
Assumptions
your server responds to IP 1.1.1.1
you use Apache 2.4 or higher
Scenario 1
For http (port 80) traffic only:
Listen 80
<VirtualHost *:80>
ServerName www.example1.com
# REST OF CONFIG
</VirtualHost>
<VirtualHost *:80>
ServerName www.example2.com
# REST OF CONFIG
</VirtualHost>
<VirtualHost *:80>
ServerName www.example3.com
# REST OF CONFIG
</VirtualHost>
Here, if you ask for http://www.example1.com, it will use the first one.
http://www.example2.com, it will use the second one, etc.
If you ask for http://1.1.1.1/, Apache does not have a name to select which
VirtualHost, so it will use the first one as it is the default. There is no way around this. You do not tell Apache which domain you want, so it defaults.
If you ask for http://www.example4.com, assuming www.example4.com == 1.1.1.1,
Apache will again use the first one since it was not able to match any other
VirtualHost to that name.
If you ask for http://www.example3.com/some_directory_error, you will receive
a 404 message from the third VirtualHost. Whatever domain you ask for, with
some illegal path, will be answered by the VirtualHost for that domain. The
validity of the request is only checked after the VirtualHost is selected.
Scenario 2
Lets assume that it works for port 80. Now for port 443...
Listen 443
<VirtualHost *:443>
ServerName www.example1.com
# REST OF CONFIG
# SSL for example1
</VirtualHost>
<VirtualHost *:443>
ServerName www.example2.com
# REST OF CONFIG
# SSL for example2
</VirtualHost>
<VirtualHost *:443>
ServerName www.example3.com
# REST OF CONFIG
# SSL for example3
</VirtualHost>
Here, whatever what your request (i.e. https://www.example1.com,
https://www.example2.com, https://1.1.1.1/, https://www.example4.com) Apache
will always use the first one. This is an SSL limitation.
The reason is that Apache only knows what IP address the requester wanted, but
not the domain name. For SSL, Apache must first negotiate with the browser
for the cipher, encryption and certificate. Then it will know which VirtualHost
to use. So for certificate negotiation, the first VirtualHost for port 443 is
always used!
Ways around this are:
1 IP address per domain. So you need 3 IP addresses on the server.
1 port per domain. You have some network device that does NAT from the
domain:443 the user asked, to the server:port you specified in your configuration.
Use SNI. Do some research on that subject. Ex https://www.digicert.com/kb/ssl-support/apache-multiple-ssl-certificates-using-sni.htm
Conclusion
You could setup a default VirtualHost. That one is the first one, and does not
specify a ServerName or ServerAlias. Only the default DocumentRoot and default
404 configuration. See Apache default VirtualHost
Tip
Split your log files per domain.
# Modify to the desired level
LogLevel debug
Listen 80
<VirtualHost *:80>
ServerName www.example1.com
# REST OF CONFIG
CustomLog logs/example1_80_access.log common
ErrorLog logs/example1_80_error.log
</VirtualHost>
<VirtualHost *:80>
ServerName www.example2.com
# REST OF CONFIG
CustomLog logs/example2_80_access.log common
ErrorLog logs/example2_80_error.log
</VirtualHost>
<VirtualHost *:80>
ServerName www.example3.com
# REST OF CONFIG
CustomLog logs/example3_80_access.log common
ErrorLog logs/example3_80_error.log
</VirtualHost>
This way you will know what is going on, per VirtualHost.
You already have a global log file, so any log that does not "belong" to a
specific VirtualHost will end up in there (logs/error.log).

Apache does not pick up default index file when I enter domain name

I installed an ubuntu server 16.04 and LAMP, it works very well and I can load default web by using ip address.
Also I created a new virtual host by domain synappse.ir. If I enter synappse.ir/index.html, it loads the page and there is not any issue but when I enter just the name of the domain without index.php, it can not find or load the index.html file!
Here is my config file for virtual host :
<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 ServerNamei
# 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 nasser.man#gmail.com
ServerName synappse.ir
ServerAlias synappse.ir
DocumentRoot /var/www/synappse.ir
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}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
#<Directory /var/www/html>
# Options Indexes FollowSymLinks MultiViews
# AllowOverride All
# Require all granted
#</Directory>
# 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>
Is there any other configuration for enabling this feature?
Sorry, pages were cached, every thing is ok.

Set different data/folders for different domains on apache

So I have Ubuntu 16 installed with LAMP and couple of other things on it (like FTP server...).
IP of my VPS is 1.2.3.4.
I have 2 domains, example.com and mydomain.com - both of these domains have their A record pointed at 1.2.3.4
If I access 1.2.3.4 and example.com and mydomain.com in my browser, all those three are showing the SAME data, specifically the contents of /var/www/html - if I change content of this directory it affects example.com and mydomain.com and the 1.2.3.4.
Now how can I set additional folders for domains to read from? I want different data on example.com and on mydomain.com - I want to make them read from different folder on server. How can i setup this please?
What you want to achieve is technically defined as setting virtual hosts which could be set using the following steps:
Under your Apache configurations directory, usually at /etc/apache2/, you will find a directory named sites-enabled.
For each of your domains, you will need to configure a special configuration file in order to point them to the right direction. The name of the file is typically your-domain.conf.
Here's an example of the file:
<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 your_domain
ServerAlias www.your_domain
ServerAdmin webmaster#your_domain
DocumentRoot website_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
<Directory website_directory>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
After saving the file you will need to restart the Apache server
/etc/init.d/apache2 restart
Repeat the above steps for each of your domains.
If everything goes right, your site will show when you access your domain.

Apache2 - Mod_rewrite and .htaccess

I am using Ubuntu 14.04 and apache 2.
Here is my phpinfo file: https://www.vivashost.com/phpinfo.php
Here is my .htacess file:
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^feature-pricing-tables.html$ feature.html
Here is my /etc/apache2/sistes-available/000-default.conf file:
<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
DocumentRoot /var/www/html
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ServerName vivashost.com
Redirect "/" https://www.vivashost.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>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
But when i try to open https://www.vivashost.com/feature.html it is giving me 404 error.
I am trying to make a rewrite rule that when you open feature.html apache2 must load the content from feature-pricing-tables.html file.
Where is my mistake, can you please help me out fix this thing ?
Thanks in advance!
This is a very common mistake that is made: You've declared the rule backwards.
Currently, your rule says that if I access feature-pricing-tables.html, then load up the content of feature.html.
Use this instead:
RewriteRule ^feature.html$ feature-pricing-tables.html [L]
Also, the L flag is necessary here - in case you add any other rules, you want to stop processing if there's a match for this rule.

show home page through tomcat without changing url

I have tomcat running behind Apache. I also have Spring security to handle authorization and authrntication and Struts 2 as my web layer framewok.
Here is my requirement:
1) I want to have a home page which shows some data which is dynamic(like categories) which has to be fetched from database and rendered dynamically.
2) I want to display above page when I hit "mysite.com" in address bar without changing the URL ie. browser address bar must show "mysite.com only.
I could have easily kept this home page as index.html on my virtual host's documentroot location. However I cannot do this as some content is generated dynamically.
Another option is to keep this on tomcat and ask apache to forward the request to tomcat. however this changes the URL on my address bar.
How can I handle this? Can ForwardDirectories option in JK_MOD be used?
To serve dynamic content from Tomcat to a specific domain do the following:
Create a virtual host on your apache web server that handles "mysite.com".
Map the whole content of your virtual host to Tomcat through mod_jk:
JkMount / tomcatsJVMRouteName
JkMount /* tomcatsJVMRouteName
Create another host in your Tomcats server.xml that handles "mysite.com".
Deploy your application as default application (webapps/ROOT-directory).
Now Lets say I have a webapp "mysite" running on tomcat which is behind apache. This mysite webapp has a domain name "mysite.com".
When I hit "mysite.com" it must return a home page with dynamic content. So I add this as index.jsp in webapps/mysite/ directory.
Follwing is the virtual host I wrote for mysite app:
<VirtualHost *:86>
ServerAdmin webmaster#dummy-host.example.com
DocumentRoot "D:/var/www/html/mysite"
ServerName mysite.com
ServerAlias www.mysite.com
ErrorLog "logs/mysite-error.log"
CustomLog "logs/mysite-access.log" common
<Directory "D:/var/www/html/mysite">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI
#MultiViews
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.4/mod/core.html#options
# for more information.
#
Options -Indexes +FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride None
#
# Controls who can get stuff from this server.
#
Require all denied
Require local granted
</Directory>
JkMount /mysite/* localtomcat
ProxyRequests Off
ProxyPreserveHost On
ProxyPass /mysite/ !
ProxyPass / http://localhost:8080/mysite/
ProxyPassReverse / http://localhost:8080/mysite/
</VirtualHost>
So, Here are my questions on above implementation :
1)What I have done is mixing the JKMount of mod_jk and proxypass of mod_proxy.Even though
this works how standard it is
2)Does it have any serious side effects?
3)What could be alternative solution?