xampp - mysite.local redirects to xampp folder - apache

I've been battering my head against this all evening and can't see where I'm going wrong. I want to set a host, mysite.local, on xampp and have followed all the instructions, but I keep getting redirected to mysite.local/xampp.
Any ideas where I'm going wrong here? The paths are correct, and I've restarted Apache :)
I edited my hosts file to add:
127.0.0.1 mysite.local
I edited extra/httpd-vhosts.conf:
NameVirtualHost localhost:80
<VirtualHost localhost:80>
ServerName localhost
DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs"
<Directory "/Applications/XAMPP/xamppfiles/htdocs">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Deny,Allow
Allow from all
</Directory>
</VirtualHost>
<VirtualHost localhost:80>
<Directory "/Applications/XAMPP/xamppfiles/htdocs/wd">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Deny,Allow
Allow from all
</Directory>
DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs/wd"
ServerName mysite.local
</VirtualHost>

I've just got the very same problem yesterday. Even if the steps you did are correct in a context, you need to do some more tasks ;)
You also need to edit Apach'es httpd.conf referring to your new VirtualHost like this:
# Your great site!
<Directory "/Applications/XAMPP/xamppfiles/htdocs/wd">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
With this alone you'll be able to access http://mysite.local without the redirection to the XAMPP splash screen BUT you'll see the directories of your proyect (at least if you don't have and index in the root folder)
If you need to load a file from a folder (for example /public/index.php) you'll need to use an .htaccess file. Remember this file must be in the folder(s) you want to have control. So for example, an .htaccess file located at the root of your project to redirect to the /public/index.php file you must do it this way:
RewriteEngine On
RewriteBase /
RewriteRule ^.*$ public/index.php [NC,L]
Just remember to use the correct regular expression you need and don't forget to take preventive measures with more security in a production website ;) I wish I've helped you out =)

Related

Vhosts not redirecting

I have a server running Ubuntu 14.04 LTS and I am trying to set up vhosts. What I did already is,
1) Created 2 files desktopia.be.conf and everybodycreative.be.conf which look like this
desktopia.be.conf:
<VirtualHost *:80>
ServerAdmin your_email_address
ServerName desktopia.be
ServerAlias www.desktopia.be
DocumentRoot /var/www/desktopia
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/desktopia>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
</VirtualHost>
everybodycreative.be.conf:
<VirtualHost *:80>
ServerAdmin your_email_address
ServerName everybodycreative.be
ServerAlias www.everybodycreative.be
DocumentRoot /var/www/everybodycreative
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/everybodycreative>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
Under the www folder, I made 2 folders named desktopia and everybodycreative.
After I did that, I ran the following commands
sudo a2ensite desktopia.be
sudo a2ensite everybodycreative.be
and restarted the apache2 service.
Now the problem is that when I connect on one of the 2 domain names, I just get to see the content of my www folder as you can see here http://desktopia.be/
If anyone can tell me where I should look or what more information is needed to fix this problem, please ask me so that I can fix this. This has been bothering me for a few days already and I need this fixed asap.
Thanks for helping me already :)
I think you'll need to run
a2enmod rewrite
to turn on rewrite module.
Then in the relative folder .htaccess
RewriteCond %{HTTP_HOST} ^(.+)\.desktopia\.be
RewriteCond %{HTTP_HOST} !^www\.desktopia\.be [NC]
RewriteRule ^(.+)$ /var/www/desktopia/%1/$1
same for other url,
I haven't tried it so you may need to modify something in the .htaccess folder code
You need to enable the NameVirtualHosts directive in your config.

Redirect to a subfolder in Apache virtual host file

I have Joomla installed on a webserver running Ubuntu Server 12.04. The Joomla folder is located at /var/www/cms/.
My vhost file at /etc/apache2/sites-enabled/default has the following content:
<VirtualHost *:80>
ServerName domain.com/
Redirect permanent / https://domain.com/
</VirtualHost>
<VirtualHost *:443>
ServerAdmin webmaster#localhost
ServerName domain.com:443
DocumentRoot /var/www/cms
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/cms>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
(...)
</VirtualHost>
At the moment, all the requests to domain.com and anything entered after that like domain.com/example gets directed and processed by Joomla which either redirects to a proper page or returns a custom 404 error. This all works.
Now, I would like to filter all the requests that go to domain.com/subfolder before they get processed by Joomla and redirect them to /var/www/subfolder (instead of my root folder at /var/www/cms/).
I believe the file in /etc/apache2/sites-enabled/default (seen above) is the right place to define such a redirect, however I have not been able to figure out at what position and how to achieve this.
You should add to your configuration:
Alias /subfolder /var/www/subfolder
<Directory /var/www/subfolder>
Order allow,deny
allow from all
</Directory>
and fit the configuration between "Directory" to your needs.
See the Apache documentation to have more informations.

.htaccess rewrites not being read

I have the following in htaccess:
RewriteEngine on
RewriteRule ^list/([A-Za-z0-9_\.-]+).html?$ list.php?table=$1 [QSA,L]
In virtualhosts:
ServerName localhost
DocumentRoot "c:/wamp/www"
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
<VirtualHost *:80>
DocumentRoot "c:/wamp/www/kurz/site/www"
ServerName kurz.local
<Directory c:/wamp/www/kurz/site/www>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
in apache config:
DocumentRoot "c:/wamp/www/"
<Directory />
Options FollowSymLinks
AllowOverride All
Order deny,allow
Deny from all
</Directory>
Now the weird problem is:
there is a rewrite happening, even AFTER i delete the .htaccess, I tried also removing ALL other sites in the www folder, but there's still a rewrite happening from somewhere (do these things cache? i tried clearing browser cache and all that),
BUT
if I put some jibberish in the .htaccess, i get a server error, so I know it is being read!
the other problem is that the rewrite is not passing any variables,
this link works:
http://kurz.local/admin/list/pages.html
but it seems to take to:
http://kurz.local/admin/list.php
instead of
http://kurz.local/admin/list.php?table=pages
online this setup is working, but locally it's not
any ideas ?
i'm really puzzled!
You haven't mentioned if you restarted the server? editing server config files needs a restart, but I believe .htaccess file changes do not need apache server restart.
Your server doc root is:
c:/wamp/www/
Your virtual host doc root is inside the above, I don't think that is allowed.
It should be :
c:/wamp/vhosts/site1root
c:/wamp/vhosts/site2root
etc.
Also see this: https://httpd.apache.org/docs/2.2/vhosts/name-based.html

Symfony 1.4 under a userdir in Apache

I have users who want to run their own Symfony projects under their home directories, but I can't get Symfony to work properly. In my Apache2 config file, I set the userdir as:
UserDir sfproject/web
But the DocumentRoot has to be:
/var/www/sfproject/web
This requirement is there because when we deploy the code to production, we don't want to change the Apache config file. And everything is going to be under that directory.
The problem is that when we go to a user directory: dev.server.com/~asdf
Symfony gives a 404 error: Empty module and/or action after parsing the URL "/index.php" (/).
I don't understand what's wrong. We want them to see their individual projects in their home directories. I looked at some other people setting up Symfony in shared hosting environments, but this is not a shared hosting environment. This is a dedicated server and I have root. Thank you for your help. Here is the relevant parts of my Apache config:
UserDir sfproject/web
<Directory "/usr/share/php/data/symfony/web/sf">
AllowOverride All
Allow from All
</Directory>
<VirtualHost *>
DocumentRoot "/var/www/sfproject/web"
DirectoryIndex index.php
<Directory "/var/www/sfproject/web">
AllowOverride All
Allow from All
</Directory>
Alias /sf /usr/share/php/data/symfony/web/sf
<Directory "/usr/data/symfony/web/sf">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
I think something like the following would be closer to a solution.
<VirtualHost *>
DocumentRoot "/var/www/sfproject/web"
DirectoryIndex index.php
<Directory "/var/www/sfproject/web">
AllowOverride All
Allow from All
</Directory>
# or is the dir /usr/share/php/data/symfony/data/web/sf ?
Alias /sf /usr/share/php/data/symfony/lib/vendor/symfony/data/web/sf
<Directory "/usr/share/php/data/symfony/lib/vendor/symfony/data/web/sf">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
The paths from your excerpt does not look good I guess. Try it out and let us know if it works.

Moveable type images not displayed

I installed Moveable type on a ubuntu box.
The admin section works great.
However the front page does not. The images and CSS are not displayed.
This is coming from the apache error log:
Permission denied: exec of '/var/www/mt/example/styles.css' failed
Premature end of script headers: styles.css
I think it's related to my apache config. Since i call the admin section using the localhost, but i use the example.com for the front page, which is the part that doesnt work.
This is my apache config:
NameVirtualHost *
<VirtualHost *>
ServerAdmin chris#example.com
ServerName mt.example.net
DocumentRoot /var/www/mt
Alias /mt-static /var/www/mt/mt-static
<Directory /var/www/mt/mt-static>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias / /var/www/mt/
<Directory /var/www/mt>
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *>
ServerAdmin chris#example.com
ServerName example.com
ServerAlias example.com www. example.com
DocumentRoot /var/www/example
Alias /mt-static /var/www/mt/mt-static
<Directory /var/www/mt/mt-static>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
Redirect /mt.cgi http://mt.example.net/mt.cgi
</VirtualHost>
it because the directory where the css file is located (var/www/mt/example/) is a sub-directory of one which is declared to be a script in (/var/www/mt) with Options +ExecCGI
Directories inherit the options of their parents
It sounds like Apache has tried to run the .css file as an executable. The only thing which I can suggest is that you might have a css file which has an executable permission, for some reason, so Apache tries to execute it. Try
chmod a-x
on the CSS file and see if it makes a difference.
Sometimes files copied from Windows have executable set when they shouldn't.