Url rewriting not working in WAMP Subdomain - .htaccess

I created a Subdomain under my WAMP server for mobile site and it uses IP address as the domain name which is 192.168.106.1
But the issue is that when I try to rewrite a url in my .htaccess file, I doesn't work. And I use a duplicated .htaccess file which works for the localhost
Below is my server configuration for the domain name in my httpd.conf file
<VirtualHost 192.168.106.1>
#LoadModule rewrite_module modules/mod_rewrite.so
# The name to respond to
ServerName m.localhost
# Folder where the files live
DocumentRoot "C:/wamp/www/mobile/"
# A few helpful settings...
<Directory "C:/wamp/www/mobile/">
Allow from all
Order Allow,Deny
# Enables .htaccess files for this site
AllowOverride All
</Directory>
# Apache will look for these two files, in this order, if no file is specified in the URL
DirectoryIndex index.html index.php
</VirtualHost>
I also removed the comment tag on the second line but it still not working.
Please anyone with a solution?

Here is a solution
First make sure you go to your C:/wamp/bin/apache/YOUR APACHE VERSION/conf and open up your httpd.conf file and uncomment this line
#Include conf/extra/httpd-vhosts.conf
So it will look like this
Include conf/extra/httpd-vhosts.conf
Then also open up your host file located in C:/windows/System32/drivers/etc and add this (your ip address to the configuration)
#add the sub-domain name, in this case I use mobile, it can be anything
192.168.106.1 mobile.localhost
192.168.106.1 192.168.106.1
Then finally and most importantly, open up your vhost file in C:/wamp/bin/apache/YOUR APACHE VERSION/conf/extra/httpd-vhosts.conf and add this to the file
<VirtualHost *:80>
DocumentRoot "C:/wamp/www/mobile"
ServerName m.localhost
Options Indexes FollowSymLinks
<Directory "C:/wamp/www/mobile">
AllowOverride All
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
#If you want to allow access from your internal network
# For specific ip addresses add one line per ip address
Allow from 192.168.106.1
# For every ip in the subnet, just use the first 3 numbers of the subnet
#Allow from 192.168.0
</Directory>
</VirtualHost>
Then restart your WAMP server and it works

Related

How to redirect wildcard subdomain to my domain

I would like to redirect wildcard subdomain to my actual domain.
like this (I already have error.example.com)
dsfas.example.com -> error.example.com
but I could not do this after hours of searching. Is there a solution to this.
I am using apache
You can do this by creating a “catch-all” Apache configuration and redirecting to the domain you specify.
Create an Apache configuration file with a name like zzz-catchall.conf (so that it’s the last file alphabetically in the directory) and paste this into the file:
<VirtualHost *:80>
ServerAdmin none#noaddy.net
DocumentRoot /var/www/catch/public
ServerName catch.example.com
ServerAlias *.example.com *.*
DirectoryIndex index.php index.html
ErrorLog ${APACHE_LOG_DIR}/catch-error.log
CustomLog ${APACHE_LOG_DIR}/catch-access.log combined
<Directory /var/www/catch/public>
Options FollowSymLinks
AllowOverride All
Order Allow,Deny
Allow From All
</Directory>
</VirtualHost>
Be sure to change the domain names and directories accordingly.
In the /var/www/catch/public (or whatever) directory, you can set up a redirect a number of ways, but .htaccess would be simple enough:
Redirect 301 / https://error.example.com/
Ensure the virtual host configuration file is enabled, and reload Apache. That should get you going 👍🏻

Cloud Agent, Apache, and drupal's .htaccess

Installed Apache and Cloud Agent.
Agent collects information from mod_status. Everything is ok.
However, when I add drupal files (with .htaccess), Agent can't collect stat anymore.
I already tried many configuration and now I am super confused about VirtualHosts. I used standard agent's configuration for virtualhost:
ExtendedStatus on
<VirtualHost 127.0.0.1:80>
ServerName local-stackdriver-agent.stackdriver.com
<Location /mod_status>
SetHandler server-status
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Location>
</VirtualHost>
In http.conf I changed only DocumentRoot.
Can someone please explain me why the requests go to drupal's folder, and not to local-stackdriver-agent.stackdriver.com VirtualHost?

Subdomain not working on Apache/Linux

I'm trying to set up a subdomain for on a client's web server. It's a CentOS server running Apache. So say the website is "example.com". I'm trying to create "bugs.example.com".
So far, I've added to the vhost.conf file the subdomain info:
<VirtualHost *:80>
ServerName bugs.example.com
ServerAlias bugs.example.com
DocumentRoot /var/www/www.bugs.example.com
<Directory "/var/www/www.bugs.example.com">
AllowOverride ALL
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
I've added the server's IP address and the subdomain to /etc/hosts:
111.222.333.444 bugs.example.com
I've created the directory for the website files, and an index page at:
/var/www/www.bugs.example.com/index.html
Sadly, I still get a "Server not found" error when I go to bug.example.com. What am I missing here? The example.com domain name is registered through GoDaddy.com. Is there something that needs to be done there?

Resolving virtual hosts apache 2

I'm trying to setup my apache server to access certain folders when I type addresses like test1.example.com test2.example.com etc.
So far I read and did many things but with no success yet. I'll be very thankful if you can help me.
So to start I'm using ubuntu 12.10 as my desktop and I've set up apache server there. I've added example.com in hosts resolving to 127.0.0.1. So far no problems. I've enable vhost_alias and mod_rewrite in apache and I'm using this for my virtual server
NameVirtualHost *:80
UseCanonicalName Off
<VirtualHost *:80>
ServerName example.com
ServerAlias *.example.com
RewriteEngine On
RewriteCond %{HTTP_HOST} !^(www\.)?([^\.]+).example.com$
RewriteRule ^(.*) $1 [F]
VirtualDocumentRoot /home/example/server/projects/%1/public_html
<Directory />
Options FollowSymLinks
AllowOverride all
</Directory>
<Directory /home/radoslav/server/projects>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
</Directory>
#log file for this server
CustomLog /var/log/apache2/example.com.log combined
</VirtualHost>
But when I open test.example.com it says that browser can find test.example.com, no matter that I have this directory in the path specified. Just to clear things up apache have permissions to read this directory so it's not this. When I ping example.com from console I get ping but if I ping test.example.com I get error that can not find host. As you can see obviously it's not resolving the adress no matter that I've setup everything correcly.
Any help guys?
You need to add test.example.com and any other hostnames you want to use in the host file. The host file does not supports wildcard.

Problems with Apache Virtual Hosts

I have recently just set up a RHEL based server running two domains. However, I am having difficulty hitting both domains from the browser. My config is:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName domainA.com
ServerAlias domainA.com *.domainA.com
DocumentRoot /home/domainA/public_html
<Directory "/home/domainA/public_html">
allow from all
Options +Indexes
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName domainB.com
ServerAlias domainB.com *.domainB.com
DocumentRoot /home/domainB/public_html
<Directory "/home/domainB/public_html">
allow from all
Options +Indexes
</Directory>
</VirtualHost>
The problem is when I navigate to domainA.com I hit the correct Virtualhost (which is fine), however when I navigate to domainB.com it displays the Apache Test page.
Edit
I have a Firewall between the webserver and the web. I tested the rules governing Domain A and Domain B.
Domain A reaches target and a status 200 is returned.
Domain B reaches target and a status 403 (permission denied) is returned
What you need to do is take a look at sites-enabled and sites-available.
Here's the first entry when Googling: http://www.debian-administration.org/articles/412
Looks reasonable and should help you integrate that.
The problem is that you need separate entries for all the sites you want to run on this apache2. Simple entries in your config file don't do it. Only the first works, the rest is more or less ignored. Creating separate entries with sites-enabled and sites-available is the way to go here.

Categories

Resources