I have created a subdomain for one of my domains, now I have the following issue:
if I go to blog.domain.com it shows me index.html which is fine
if I go to blog.domain.com/index.html it shows me index.html which is fine
if I go to blog.domain.com/somelog.txt it shows me somelog.txt which is fine
BUT if i try to access any .php file (wordpress) it will show me 404 page not found.
What am I doing wrong? Did I setup apache the wrong way?
the following info in apache/httpd.conf:
<VirtualHost 00.00.00:80>
ServerAdmin info#domain.com
ServerName domain.com
ServerAlias domain.com
DocumentRoot /var/www/domain.com
<Directory /var/www/domain.com>
Order Deny,Allow
Allow from all
Options -Indexes
</Directory>
</VirtualHost>
And this is the newly added subdomain:
<VirtualHost 00.00.00:80>
ServerAdmin info#domain.com
ServerName blog.domain.com
ServerAlias blog.domain.com
DocumentRoot /var/www/domainBLOG
<Directory /var/www/domainBLOG>
Order Deny,Allow
Allow from all
Options -Indexes
</Directory>
</VirtualHost>
Related
I want to set up the subdomain "shop" on my Apache 2.2 server on Windows/XAMPP and it redirects to "index.html" if I enter "shop.localhost" as the URL but once I try to connect via my domain "sv443.net" it redirects to my document root ("/index.html" instead of "/shop/index.html"). Connecting to "sv443.net/shop/" works fine though and even redirects to "index.html".
I'm using Cloudflare to handle the DNS stuff and added these records (I cut off the IP address part):
This is my httpd-vhosts.conf:
NameVirtualHost localhost:80
<VirtualHost localhost:80>
ServerName localhost
ServerAdmin sven.fehler#web.de
DocumentRoot "c:/users/sv443/desktop/mamp htdocs"
<Directory "c:/users/sv443/desktop/mamp htdocs">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
<VirtualHost shop.localhost:80>
ServerName shop.localhost
ServerAdmin sven.fehler#web.de
DocumentRoot "c:/users/sv443/desktop/mamp htdocs/shop"
<Directory "c:/users/sv443/desktop/mamp htdocs/shop">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
And this is my hosts.dat:
(only comments)
2.205.169.73 sv443.net
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
127.0.0.1 localhost shop.localhost
Also I added this .htaccess file to the shop directory to redirect to the index.html if a 403 or 404 is encountered - removing this file doesn't fix my problem:
ErrorDocument 403 /shop/index.html
ErrorDocument 404 /shop/index.html
If someone tries to connect I get this error message in the Apache error.log:
AH01630: client denied by server configuration: C:/Users/Sv443/Desktop/MAMP htdocs/shop/.html
Thanks for any help!
If you can get content by explicitly specifying "/index.html" but not with "/", you should add DirectoryIndex index.html in your configuration, after loading mod_dir. This will define the default file to look for when it is not specified.
For your VirtualHost:
<VirtualHost *:80>
ServerName localhost
ServerAlias www.example.com
ServerAlias example.com
LogLevel debug
CustomLog "logs/example_access_log" combined
ErrorLog "logs/example_error_log"
[... REST OF CONFIGURATION ...]
</VirtualHost>
<VirtualHost *:80>
ServerName shop.localhost
ServerAlias shop.example.com
LogLevel debug
CustomLog "logs/shop_access_log" combined
ErrorLog "logs/shop_error_log"
[... REST OF CONFIGURATION ...]
</VirtualHost>
Apache decides which VirtualHost to use for the request based on the domain in the request. If it does not find a match, it uses the first one in the file (here localhost). Therefore you are not pointing to your "shop" sub-domain, unless you specify it in the VirtualHost for it, via ServerAlias ....
I'm trying to configure my apache vhosts file to have a localhost/something hostname and "alias" hostnames. I'm working with google api's currenctly and they are not accepting custom aliases as url's, so I can't make it work with my custom url's. Any thoughts of what to do? My current config that's not working:
<VirtualHost 127.0.0.1:80>
ServerName localhost/go
ServerAlias localhost/go
DocumentRoot "D:/username/Web/server.dev/go"
</VirtualHost>
<Directory "D:/username/Web/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Deny,Allow
Allow from all
Require all granted
</Directory>
<VirtualHost *:80>
ServerName api.server.dev
ServerAlias api.server.dev
DocumentRoot "D:/username/Web/server.dev/api"
</VirtualHost>
##... more custom urls with subdomains cut out because it's unnecessary
<VirtualHost *:80>
ServerName adstrck.server.dev
DocumentRoot "D:/username/Web/server.dev/adstrck"
</VirtualHost>
### ALL OTHERS ###
<VirtualHost *:80>
ServerName www.server.dev
ServerAlias server.dev *.server.dev
DocumentRoot D:/username/Web/server.dev
</VirtualHost>
When I'm trying to access 127.0.0.1/go or localhost/go I get an internal server error.
Maybe what you want is something like this
<VirtualHost 127.0.0.1:80>
ServerName localhost
ServerAlias server.dev *.server.dev
DocumentRoot "D:/username/Web/server.dev"
</VirtualHost>
<Directory "D:/username/Web/server.dev">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Deny,Allow
Allow from all
Require all granted
</Directory>
Then use a url like http://localhost/go to view the site.
Depending on your OS/browser, you may be able to add a development subdomain to localhost. E.g.
<VirtualHost *:80>
ServerName dev1.localhost
## rest of your config
## e.g. ServerAlias my.website.on.the.internet.com
DocumentRoot /var/www/dev1
</VirtualHost>
<VirtualHost *:80>
ServerName dev2.localhost
DocumentRoot /var/www/dev2
</VirtualHost>
# Default / catch-all
<VirtualHost *:80>
DocumentRoot /var/www/html
</VirtualHost>
I then pointed my browser to dev1.localhost and that resolved to dev1 and likewise for dev2.localhost and localhost by itself resolved to the default apache page.
This resolved my similar problem. Tested on Apache in a Debian WSL. Worked on Windows Chrome, failed on Windows Firefox. Based on this SO: https://stackoverflow.com/a/35124491
I want to setup a virtual host in my localhost, so I can access my Laravel app like this: demo.example.com. I have added a custom conf file: etc/apache2/sites-available/example.com.conf with the following contents:
<VirtualHost *:80>
ServerAdmin username#gmail.com
ServerName example.com
ServerAlias www.example.com
ServerAlias demo.example.com
ServerAlias www.demo.example.com
DocumentRoot /var/www/example/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/example/public>
AllowOverride All
</Directory>
</VirtualHost>
Contents from /etc/hosts file:
127.0.0.1 localhost
127.0.1.1 username-pc
127.0.0.1 example.com
127.0.0.1 www.example.com
127.0.0.1 http://exaple.com
127.0.0.1 demo.example.com
With the above settings if I access the url demo.example.com it works. But if I try to access other routes like demo.example.com/login I get apache 404 error: The requested URL /login was not found on this server. How do I fix this?
Note that this is not laravel's NotFoundHttpException.
place this under your directory tag
<Directory /var/www/example/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
I am having trouble accessing the Joomla administrator page in a subdomain.
Here's what it's like, the site is http://test.com and the admin page must be http://admin.test.com
I am using a WAMP server with virtual host enabled.
here's my httpd-vhosts.conf:
<VirtualHost *:80>
ServerAdmin admin#test.com
DocumentRoot "c:\wamp\www\test"
ServerName test.com
ServerAlias www.test.com
ErrorLog "C:\wamp\www\test\logs\error.log"
CustomLog "C:\wamp\www\test\logs\access.log" common
<Directory "c:/wamp/www/test">
AllowOverride All
Order Deny,Allow
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin admin#test.com
DocumentRoot "C:\wamp\www\test\administrator"
ServerName admin.test.com
ServerAlias www.admin.test.com
ErrorLog "C:\wamp\www\test\logs\error.log"
CustomLog "C:\wamp\www\test\logs\access.log" common
<Directory "c:/wamp/www/test/administrator">
AllowOverride All
Order Deny,Allow
Allow from all
</Directory>
</VirtualHost>
test.com works fine, but the admin doesn't. It only displays a white blank page. I also noticed that the redirection works in admin since the page title loads the admin page title.
I'm using Joomla! 3.4.4 Stable, and WAMP Server with Apache/2.4.9 and PHP 5.5.12.
In your configuration.php file under your Joomla website, set $error_reporting to "maximum". This will show you what the error really is and will give you pinpoints on how to fix it.
I activated the userdir mod with apache2 and configure my domain to get the content of the www folder in my home.
I create a Virtualhost for the main domain which works good.
But now i would like to automatically add a subdomain for each folder in my /home/user/www/
Here is the virtualhost i code, but it redirect all the subdomains to the /home/user/www/
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName mysite.com
ServerAlias *.mysite.com
DocumentRoot /home/user/www/
UseCanonicalName Off
VirtualDocumentRoot /home/user/www/%1
<Directory /home/user/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/error.mysite.log
LogLevel warn
CustomLog /var/log/apache2.mysite.log combined
</VirtualHost>`
Try changing:
VirtualDocumentRoot /home/user/www/%1
to:
VirtualDocumentRoot /home/user/www/%0
You can read more about this feature at mod_vhost_alias.