I have Magento installed on my site at mydomain.com/magento. I'm happy with it to stay in this directory, however when people visit the site directly (i.e. mydomain.com) I would like this to open the Magento folder. How can I do this?
Thank you very much.
You have to make your server redirect "mydomain.com" to the directory you have installed Magento at. If you are using apache you could add a virtualhost like the one below to your httpd.conf:
<VirtualHost *:80>
ServerName mydomain.com
DocumentRoot "/yourpath/magento"
CustomLog "/tmp/access_log" common
LogLevel debug
ErrorLog "/tmp/error.log"
<Directory "/yourpath/magento">
Options FollowSymLinks Multiviews Indexes
MultiviewsMatch Any
# Rewrites to allow links
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# We are not allowing any directive contained in a .htaccess file
AllowOverride None
# We grant all permissions
Require all granted
</Directory>
Related
I have configured httpd in my fedora and I checked everything is true but i get
access forbidden
I have tested everything about .htaccess but still getting access forbidden. also, my laravel folder permissions are correct.
I tested a sample project while installing httpd it worked perfectly with no 'access forbidden' message.
this is my httpd config
<VirtualHost *:80>
ServerName test.com
ServerAlias www.test.com
DocumentRoot /home/myuser/gitlab/register/public
<Directory /home/myuser/gitlab/register/public>
DirectoryIndex index.php
AllowOverride All
Require all granted
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
this is my htaccess in laravel public folder
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
your probably creating the issue by mixing old Apache syntax with new Apache syntax, modern versions of Apache should be something like this...
<VirtualHost *:80>
ServerName test.com
ServerAlias www.test.com
DocumentRoot /home/myuser/gitlab/register/public
<Directory /home/myuser/gitlab/register/public>
DirectoryIndex index.php
AllowOverride All
Require all granted
# Order allow,deny
# Allow from all
</Directory>
</VirtualHost>
I found the problem.
it is because of the
SELinux
ubuntu does not uses SELinux by default but RedHat distributions use it by default. SELinux prevents apache to access the home directory for the sake of security so if you disable or put it to Permissive mode, apache can access your home directory to load the web project. if you do not want to disable SELinux so the correct location for web applications is in /var/www/ folder
so if we change httpd config to
<VirtualHost *:80>
ServerName test.com
ServerAlias www.test.com
DocumentRoot /var/www/gitlab/register/public
<Directory /var/www/gitlab/register/public>
DirectoryIndex index.php
AllowOverride All
Require all granted
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
it works fine
when I access the application from same computer where wampServer is installed every thing works fine whether I access it using localhost or Ip of the computer but when I put wamp server online and access the same app from another computer using the Ip of the computer where wamp is installed routes doesn't work for me only root page is being accessed and if I click on any other link I get 404 error
Here is .htaccess file in public folder
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteBase /laravel/itman/public/
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
httpd-vhosts.conf file in wamp\bin\apache\apache2.4.41\conf\extra\httpd-vhosts.conf
<VirtualHost *:80>
ServerName localhost
ServerAlias localhost
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
The apache virtual host should point to the public directory for your laravel project.
e.g.
<VirtualHost *:80>
ServerName localhost
ServerAlias localhost
DocumentRoot "${INSTALL_DIR}/www/public"
<Directory "${INSTALL_DIR}/www/public">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
I have Laravel 6.4 installed on ubuntu 18.04 with php 7.2 and apache2. I have built a case study to develop an api and when I execute the php artisan serve command and use postman to do the query everything works fine. But if I create a virtualhost, I can see the website without problems, however, when executing a query through the postman I get the 404 error.
The .htaccess file is the one that brings by default laravel:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
and my virtualhost is the following:
<VirtualHost test-api.local:80>
ServerName test-api.local
DocumentRoot /var/www/html/restlav/public
DirectoryIndex index.php
ErrorLog ${APACHE_LOG_DIR}/test-api.local-error.log
CustomLog ${APACHE_LOG_DIR}/test-api.local-access.log combined
<Directory "/var/www/html/restlav">
Options +FollowSymLinks
RewriteEngine On
AllowOverride None
Require all granted
</Directory>
</VirtualHost>
I have already tried to make the changes that are suggested in the official documentation and nothing. The rewrite module is enabled. If anyone could help me I appreciate it in advance.
In the <Directory> section you need to set AllowOverride to All:
<VirtualHost test-api.local:80>
ServerName test-api.local
DocumentRoot /var/www/html/restlav/public
DirectoryIndex index.php
ErrorLog ${APACHE_LOG_DIR}/test-api.local-error.log
CustomLog ${APACHE_LOG_DIR}/test-api.local-access.log combined
<Directory "/var/www/html/restlav">
Options +FollowSymLinks
RewriteEngine On
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Also make sure to enable the rewrite module in the apache server:
$ sudo a2enmod rewrite
And don't forget to finally restart the apache server to make the changes come into effect:
$ sudo systemctl restart apache2
on my server I have wordpress site on root and codeigniter project as sub folder in wordpress and I made subdomain for codeigniter project. Both are working fine without SSL Now I want to apply SSL on subdomain project while applying ssl on this I am facing issue. When I am opening site by using https://subdomain.example.com it is giving me forbidden 403 error.
Following is the example of my sites hosted on apache. I had symbolic link for my root wordpress project.
http://example.com - working fine - wordpress project on root
http://subdomain.example.com - working fine - codeigniter project under wordpress project folder
https://subdomain.example.com - getting forbidden error
Following is my apache ssl virtual host file data.
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAlias subdomain.example.com
ServerName subdomain.example.com
DocumentRoot /var/www/html/wordpress
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLCertificateFile /home/ubuntu/wordpress/cdq/my-ssl-certifications/fc1d71b08ac8aab1.crt
SSLCertificateKeyFile /home/ubuntu/wordpress/cdq/my-ssl-certifications/host.key
SSLCertificateChainFile /home/ubuntu/wordpress/cdq/my-ssl-certifications/gd_bundle-g2-g1.crt
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars
</Directory>
<Directory /var/www/html/wordpress>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
</IfModule>
htaccess of wordpress project
RewriteEngine On
RewriteCond %{HTTP_HOST} subdomain.example.com$
RewriteCond %{REQUEST_URI} !^/subfolder
RewriteRule ^(.*)$ /subfolder/$1 [L]
RewriteBase /
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
htaccess of subfolder project
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^(.*)$ /index.php/$1 [L]
There is some permission related issue in your configuration :
<Directory /var/www/html/wordpress>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
it require granted for all files. So all you have to do is make it like :
<Directory "/var/www/html/wordpress">
AllowOverride All
</Directory>
P.S. I have modified your file and you use it like :
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerAlias subdomain.example.com
ServerName subdomain.example.com
DocumentRoot /var/www/html/wordpress
<Directory "/var/www/html/wordpress">
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLCertificateFile /home/ubuntu/wordpress/cdq/my-ssl-certifications/fc1d71b08ac8aab1.crt
SSLCertificateKeyFile /home/ubuntu/wordpress/cdq/my-ssl-certifications/host.key
SSLCertificateChainFile /home/ubuntu/wordpress/cdq/my-ssl-certifications/gd_bundle-g2-g1.crt
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars
</Directory>
BrowserMatch "MSIE [2-6]" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
</VirtualHost>
There is no major change. I just modify it according to my working file. Hope it helps you.
Finally resolved the issue. Issue was with the permissions of project folder structure. Now everything is working fine
Disclaimer - I'm a total newb when it comes to this. Inherited this issue.
I just installed the SSL certificate to our website. Install seems to have gone fine. Whenever I try to access a page via https I receive a 310 - Too many redirects error. I suspect this has something to do with how my virtual host is setup but I don't know enough about what I am looking at.
Here is the code from the SSL virtual host
<VirtualHost *:443>
SSLEngine On
SSLCertificateFile "/path/file.crt"
SSLCertificateKeyFile "/path/file.key"
SSLCertificateChainFile "/path/file.crt"
ServerAdmin admins#email.com
ServerName domain.com
DocumentRoot /var/www/domain.com/www
<Directory /var/www/domain.com/www>
SSLRequireSSL
Options -Indexes +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^labs$ http://www.mdlabtests.com/ [L]
RewriteRule ^imaging$ http://prepaidimaging.com/ [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([0-9a-zA-Z]*)$ /index.php?aid=$1 [L]
</Directory>
ErrorLog /path/file.log
TransferLog /path/file.log
LogLevel warn
Alias /comp /var/www/domain.com/www/comp.php
<Location /card>
DirectoryIndex create_card.php
</Location>
php_admin_value session.cookie_domain "domain.com"
php_admin_flag session.cookie_secure off
php_admin_value open_basedir "/var/www/domain.com/:/var/www/sub_dir/cg/:/usr/share/php/"
php_value include_path ".:/var/www/domain.com/includes:/usr/share/php"
php_admin_flag file_uploads off
The page I am trying to access is https://domain.com/enrollment.php
Any ideas?
Or do you have an .htaccess file lurking on your filesystem?