I'm using Magento 1.6.2.0., Apache, Fast CGI, OpenSUSE
I have set up Multi Store successfully by redirecting a different domain using vhost.conf and vhost_ssl.conf, and by altering the .htaccess in the 'root' domain. I need to do it this way because I need 2 separate IP addresses and 2 SSL certs. The redirect works and I have been able to skin the new domain to my liking.
.htaccess:
SetEnvIf Host .*domain.* MAGE_RUN_CODE=domain_code
SetEnvIf Host .*domain.* SetEnv MAGE_RUN_TYPE=website
vhost_ssl.conf:
<IfModule mod_suexec.c>
SuexecUserGroup "user" "xxxx"
</IfModule>
DocumentRoot "/var/www/vhosts/domain.co.uk/dev.domain.co.uk"
<Directory /var/www/vhosts/domain.co.uk/dev.domain.co.uk>
<IfModule mod_fcgid.c>
<Files ~ (\.php)>
SetHandler fcgid-script
FCGIWrapper /var/www/cgi-bin/cgi_wrapper/cgi_wrapper .php
Options +ExecCGI
allow from all
</Files>
</IfModule>
SSLRequireSSL
Options -Includes -ExecCGI
</Directory>
My concern is that whenever I try to navigate to an https:// page I get a redirect loop in the browser.
I have no SSL cert set up for this domain, but to my mind this should not create this error, but rather a 'no cert' error (if anything).
I was hoping that someone might be able to point out a solution that they have had in the past.
Thanks for any time that anyone spends on this.
Related
I've inherited an existing Silverstripe 3.4 site and am setting up a new Vagrant VM for it. It has an /app directory that Grunt copies into /public-www on build. Composer pulls everything else into public-www.
Website loads fine. Home page, and subpages multiple levels deep like http://mysite.local/dev/tasks. However it's not possible to load the admin login page.
http://mysite.local/admin redirects to http://mysite.localadmin/pages
(slash removed)
http://mysite.local/admin/pages redirects to
http://mysite.localsecurity/login?BackURL=%2Fadmin%2Fpages (slash
removed again after redirecting to security this time)
http://mysite.local/security/login?BackURL=%2Fadmin%2Fpages redirects
to a 404 (Silverstripe type, not apache)
http://mysite.local/Security/login?BackURL=%2Fadmin%2Fpages (note manually changing to uppercase "Security") loads the login form, but the default dev login defined in _config.php does not work.
Surely an Apache issue. The .htaccess file is the same that is running live right now without issue. But I can't see the problem in either. The following is my apache config (/etc/apache2/sites-enabled/default.conf)
ServerName local
DocumentRoot /var/www/html
<IfModule mod_fastcgi.c>
AddHandler php56-fcgi-www .php
Action php56-fcgi-www /php56-fcgi-www
Alias /php56-fcgi-www /usr/lib/cgi-bin/php56-fcgi-www
FastCgiExternalServer /usr/lib/cgi-bin/php56-fcgi-www -socket /run/php/php5.6-fpm.sock -idle-timeout 1800 -pass-header Authorization
<Directory "/usr/lib/cgi-bin">
Require all granted
</Directory>
</IfModule>
<IfModule mod_fastcgi.c>
AddHandler php71-fcgi-www .php
Action php71-fcgi-www /php71-fcgi-www
Alias /php71-fcgi-www /usr/lib/cgi-bin/php71-fcgi-www
FastCgiExternalServer /usr/lib/cgi-bin/php71-fcgi-www -socket /run/php/php7.1-fpm.sock -idle-timeout 1800 -pass-header Authorization
<Directory "/usr/lib/cgi-bin">
Require all granted
</Directory>
</IfModule>
<IfModule mod_fastcgi.c>
<FilesMatch ".+\.ph(p[345]?|t|tml)$">
SetHandler php56-fcgi-www
</FilesMatch>
</IfModule>
<Directory "/var/www/">
AllowOverride All
</Directory>
<VirtualHost *:80>
DocumentRoot /var/www/html/mysite/public-www
ServerName mysite.local
<IfModule mod_fastcgi.c>
<FilesMatch ".+\.ph(p[345]?|t|tml)$">
SetHandler php56-fcgi-www
</FilesMatch>
</IfModule>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /var/www/phpmyadmin
ServerName phpmyadmin.mysite.local
<IfModule mod_fastcgi.c>
<FilesMatch ".+\.ph(p[345]?|t|tml)$">
SetHandler php56-fcgi-www
</FilesMatch>
</IfModule>
</VirtualHost>
I found the cause of this weird URL redirection. The /mysite/_config.php file had this in it:
Director::setBaseURL('http://mysite.local');
It looks like it was there to get around errors when /dev/build was run from the command line, which I have since seen show up, but at least now admin works. I tried adding a trailing slash, and that certainly did fix the URLs, but then I couldn't log in for some reason. Remove it entirely and I can log in.
Note those errors are complaining about this:
You probably want to define an entry in $_FILE_TO_URL_MAPPING that
covers "/var/www/html/website/public-www"
Despite exactly that being right above the setBaseURL() line I removed.
global $_FILE_TO_URL_MAPPING;
$_FILE_TO_URL_MAPPING['/var/www/html/website/public-www'] = 'http://mysite.local';
Which I think is in the wrong place in /mysite/_config.php. After moving to _ss_environment.php, all is well there too.
I have a server setup using Centos 7 and the Centos Web Panel, I am using this to host several different domains.
I want to enable AWStats for the domains, I have managed to install AWStats, I've added awstats.[domain].conf files for all the domains and I've setup cron jobs to process the logs.
I am now trying to allow each domain to see only their own data, I tried to add the awstats.pl file to their html folder:
/home/[user]/public_html/stats/awstats.pl
But calling this via http://[domain]/stats/awstats.pl gives me a 404 error.
I've also tried the following locations, all of which give the same 404 error:
/home/[user]/public_html/cgi-bin/awstats.pl
/home/[user]/public_html/stats/cgi-bin/awstats.pl
/home/[user]/public_html/awstats.pl
an example of one of my vhosts files is below:
<VirtualHost [localserverip]:80>
ServerName [domain]
ServerAlias www.[domain]
ServerAdmin webmaster#[domain]
DocumentRoot /home/[user]/public_html
UseCanonicalName Off
ScriptAlias /cgi-bin/ /home/[user]/public_html/cgi-bin/
CustomLog /usr/local/apache/domlogs/[domain].bytes bytes
CustomLog /usr/local/apache/domlogs/[domain].log combined
ErrorLog /usr/local/apache/domlogs/[domain].error.log
# Custom settings are loaded below this line (if any exist)
# IncludeOptional "/usr/local/apache/conf/userdata/[user]/[domain]/*.conf"
<IfModule mod_setenvif.c>
SetEnvIf X-Forwarded-Proto "^https$" HTTPS=on
</IfModule>
<IfModule mod_userdir.c>
UserDir disabled
UserDir enabled [user]
</IfModule>
<IfModule mod_suexec.c>
SuexecUserGroup [user] [user]
</IfModule>
<IfModule mod_suphp.c>
suPHP_UserGroup [user] [user]
suPHP_ConfigPath /home/[user]
</IfModule>
<IfModule mod_ruid2.c>
RMode config
RUidGid [user] [user]
</IfModule>
<IfModule itk.c>
AssignUserID [user] [user]
</IfModule>
<Directory "/home/[user]/public_html">
Options -Indexes -FollowSymLinks
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
</Directory>
</VirtualHost>
I'm sure there's a misconfiguration with the cgi-bin somewhere but I'm not really familiar with how this works, can anyone see why I can't load the awstats file?
Just don't use perl at all, you can get ALL of the exact same functionality with Node.js with absolutely NO setbacks at all.
You're welcome.
I have just configured my LAMP stack on my Ubuntu 14.04 distribution and want to set .htaccess up to serve a website.
I followed the tutorial https://www.digitalocean.com/community/tutorials/how-to-use-the-htaccess-file and configured a virtual host for my domain, however I am still unable to use the .htaccess file in my projects root, whenever I try to serve a page I get a 404 error.
The .conf file for my domain looks like:
<VirtualHost *:80>
ServerAdmin alexmk92#live.co.uk
ServerName alexsims.me
ServerAlias www.alexsims.me
DocumentRoot /var/www/alexsims.me
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/alexsims.me>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
I tried to change AllowOverride None to AllowOverride All but that caused an internal 500 error even after enabling mod_rewrite.
Regards,
Alex.
EDIT: .htaccess contents
#Force www:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^alexsims.me [NC]
RewriteRule ^(.*)$ http://www.alexsims.me/$1 [L,R=301,NC]
#--- Rewrite PHP files clean URL
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([A-Za-z0-9-]+)$ ?page=$1 [NC,L]
RewriteRule ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)$ ?page=$1&id=$2 [NC,L]
I have same issue with Ubuntu 15.10.
I solved this way.
First you need to enable rewrite module:
sudo a2enmod rewrite
sudo gedit /etc/apache2/apache2.conf
and replace
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
With:
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
And finally
sudo service apache2 reload
Actually what is difference between restart and reload !
restart= stop + start
reload = remain running + re-read configuration files.
We have changed configuration so we need to reload configuration.
It should help someone as I have wasted 4 hours :)
Try
Require all granted
in place of
Order allow,deny
allow from all
See the upgrade documentation for more info:
In 2.2, access control based on client hostname, IP address, and other
characteristics of client requests was done using the directives
Order, Allow, Deny, and Satisfy.
In 2.4, such access control is done in the same way as other
authorization checks, using the new module mod_authz_host. The old
access control idioms should be replaced by the new authentication
mechanisms, although for compatibility with old configurations, the
new module mod_access_compat is provided.
AllowOverride None
That's your problem, right there. The 500 error you're getting could mean that your .htaccess file is malformed - start
See http://httpd.apache.org/docs/current/mod/core.html#allowoverride
You should check if the directives you use in .htaccess are enabled.
For example if you use RewriteEngine you should have apache module rewrite enabled:
cat /etc/apache2/mods-available/rewrite.load
a2enmod rewrite
service apache2 restart
For ExpiresActive directive you should enable apache module expires:
cat /etc/apache2/mods-available/expires.load
a2enmod expires
service apache2 restart
etc.
I have a java application responding multiple domains and uses, for each domain, a specific apache virtual host. This because Apache is faster than tomcat, to serve static resources.
The need is to do that at runtime, without restart apache configuration.
To perform this action I'm using VirtualDocumentRoot directive, as described below:
AddType text/html .html .shtml
AddOutputFilter INCLUDES .html .shtml
NameVirtualHost *:80
UseCanonicalName Off
<VirtualHost *:80>
ServerName domain.com
ServerAlias *
# Define virtual host directory, using entire domain
VirtualDocumentRoot /path/to/whosts/%0
# Define directory access
<Directory "/path/to/whosts/">
Options -Indexes MultiViews +Includes
Order allow,deny
Allow from all
</Directory>
# Define Java Proxies
<Proxy *>
AddDefaultCharset Off
Order deny,allow
Allow from all
</Proxy>
# Allow Libs (static resources) to access apache directly
ProxyPass /libs !
ProxyPass / ajp://localhost:8009/
ProxyPassReverse / ajp://localhost:8009/
</VirtualHost>
This does not work well, because if I try to access to www.domain.com, is different than access to domain.com.
Do you think is a good idea to register a symbolic link from www.domain.comto domain.com???
Exists another way to do that? I'm really poor in apache managing...
Thank's a lot!
Ciao, Davide.
I regularly use symlinks to link multiple domains to the same webroot when doing configurations similar to this, there is no explicit harm in that solution so definitely no reason to shy away from it.
A good way would be to decide which type of URL should be the canonical one, and use mod_rewrite to redirect URLs to it - for instance, match requests to domain.com and redirect them to www.domain.com. There's plenty of tutorials on how to do this available on the web which you should be able to find easily.
Off the top of my head, you could use something like:
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.$ [NC]
RewriteRule ^(.*) http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
That would cause problems if you're using SSL, though, due to the hardcoded http://. I think you could change the RewriteRule line to the following to avoid that:
RewriteRule ^(.*) %{SERVER_PROTOCOL}://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
My web host points my "main" domain name to the root www folder. The web files for that site are located in the "www/app/webroot" folder. I currently have the site up and running using the following in the htaccess file:
RewriteBase /
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
I'm trying to start a dev site for the same site. I made a folder named "dev" in the www folder. So, the web files for this folder are in: "www/dev/app/webroot" I have a sub-domain pointing to the dev folder. When I use the same htaccess as above in the dev folder, it doesn't work because (I believe) it is inheriting the settings from the root www folder. When the page loads, it just comes up blank. How do I set up my htaccess files to allow for both sites?
Thanks in advance for any help! I'm obviously a novice at this stuff.
So we'll try to clean the things :-)
Avoid using .htaccess. All the settings in a .htaccess in a directory /foo/bar can be set in apache configuration as a Directory setting (.haccess is usefull if you provide limited access on apache conf, if you own the server don't use it).
<Directory /foo/bar>(...)</Directory>
Then you can access your sites with named based virtualhosts. Verify you have this option:
NameVirtualHost *:80
When you have it nice things can start.
This will be your virtualhost for your 1st app:
<VirtualHost *:80>
ServerName app
ServerAlias www.app.somwhere.com
ServerAlias app.somwhere.com
DocumentRoot /www/app/webroot
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /www/app/webroot>
Options Indexes FollowSymLinks
# this prevent.htaccess reading, remove if you want .htaccess
AllowOverride None
# allow web access
Order allow,deny
allow from all
</Directory>
</VirtualHost>
Most apache settings can be define here. Only for your 1st app. Apache will serve this configuration for all requests done for the site name 'app', or 'www.app.somwhere.com', or 'app.somwhere.com'. You can define a lot of alias(ServerAlias)., and only one name (ServerName).
Then if you go in your browser and type http://app/ your browser won't find the server, so set it in your /etc/hosts. This is what every people wanting to access your app should have in the hosts file until you get a real DNS (assuming your 1st app is app.somwhere.com and the second foo.somwhere.com and 92.128.52.226is your external IP):
127.0.0.1 app.somwhere.com app foo foo.somewhere.com
92.128.52.226 app.somwhere.com app foo foo.somewhere.com
And now let's add another virtualhost for your second app:
<VirtualHost *:80>
ServerName foo
ServerAlias www.foo.somwhere.com
ServerAlias foo.somwhere.com
DocumentRoot /www/foo/webroot
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /www/foo/webroot>
Options Indexes FollowSymLinks
# this prevent.htaccess reading, remove if you want .htaccess
AllowOverride None
# allow web access
Order allow,deny
allow from all
</Directory>
</VirtualHost>
And etc.
Don't forget to restart your apache. No rewrite rule. nice virtualhosts is the 1st step of a nice configuration, you will be able to define rules, directory or location specific things per name used. Even php configuration can be set per virtualhost with php_value instead of a global shared one on php.ini.
type
apache2 -S
to get the list of your virtualhosts, you'll see that the first one is the 'default' one, if apache does'nt understand the name of the requested site it will serve this default one (so you could ad a specific virtualhost on top to handle theses cases).
Try adding dev/ to the paths in lines 3 and 4 to your dev .htaccess.
Maybe you should remove the "RewriteBase /" line in the .htaccess in your dev folder?