I have setup virtual host on my localhost by using codeigniter and it is working fine. But I am not able to create wildcard subdomains. To add virtual host below are my steps on windows machine.
C:\Windows\System32\drivers\etc\hosts.txt
In this host.txt I have added below line
127.0.0.1 localhost.com
I am using xampp .I have added below lines in httpd-vhosts.conf file.
D:\xampp\apache\conf\extra\httpd-vhosts.conf
<VirtualHost localhost.com:80>
DocumentRoot "D:/xampp/htdocs/adeptra"
ServerName localhost.com
ServerAlias localhost.com
<Directory "D:/xampp/htdocs/adeptra">
Options Indexes FollowSymLinks
AllowOverride All
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "D:/xampp/htdocs/adeptra"
ServerName localhost.com
ServerAlias *.localhost.com
<Directory "D:/xampp/htdocs/adeptra">
Options Indexes FollowSymLinks
AllowOverride All
</Directory>
</VirtualHost>
Below is my .htaccess code to remove index.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
So now my question is, is it really possible to create wildcard subdomains in localhost? If yes, then please help me in this regard. Any help would be greatly appreciated.
A similar question has already been asked and answered here. Basically, no you cannot create subdomains on localhost. You need to create a local domain which is explained in the linked answer.
Related
My application is in Laravel + Vue I'v hosted on Hostinger VPS ubuntu 20.
when I type my site in Google like exptradies.com google showing all the directories as bellow image.
This is my site config
<VirtualHost *:80>
ServerName exptradies.com
ServerAlias www.exptradies.com
ServerAdmin admin#exptradies.com
DocumentRoot /var/www/html/exptradies/public
<Directory /var/www/html/exptradies>
AllowOverride All
Options +FollowSymlinks
Require all granted
ReWriteEngine On
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.exptradies.com [OR]
RewriteCond %{SERVER_NAME} =exptradies.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
Does anyone know What I'm missing in the configuration.
for the ssl I use Letsencypt cerbot.
Your web server is configured to show directory indexes. That shows a web page with a list of files for directory requests when the directory does not contain an index document. You can disable this by using
Options -Indexes
That can either go beneath AllowOverride All or in your .htaccess file.
After making the configuration change you will have to wait a couple weeks for Googlebot to recrawl those pages and stop indexing them.
Add public to your path in Directory and this probably will solve your problem
<Directory /var/www/html/exptradies/public>
AllowOverride All
Options +FollowSymlinks
Require all granted
ReWriteEngine On
</Directory>
Don't forget to restart apache service
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
I try to do my first deploy Laravel 7 + LAMP (Ubuntu).
I succeeded to install Laravel repo I can see my homepage (http://xx.xxx.xx.xxx/).
But when I try to navigate into the website I get this Error:
The requested URL was not found on this server.
I think that i've correctly installed LAMP and Laravel.
The DB is set, I've done the migration.
The problem is probably with the .htaccess, I set my in the repo folder (domain.it/repo):
IfModule mod_rewrite.c>
# That was ONLY to protect you from 500 errors
# if your server did not have mod_rewrite enabled
RewriteEngine On
# RewriteBase /
# NOT needed unless you're using mod_alias to redirect
RewriteCond %{REQUEST_URI} !/public
RewriteRule ^(.*)$ public/$1 [L]
# Direct all requests to /public folder
</IfModule>
And that's my apache2 conf:
<VirtualHost *:80>
<Directory /var/www/html>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ServerAdmin social.legambientecapannori#gmail.com
ServerName legambientecapannoriepianalucchese.it
ServerAlias www.legambientecapannoriepianalucchese.it
DocumentRoot /var/www/legambientecapannoriepianalucchese.it/legambiente/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Ah, i've
Thanks in advance
Solved :)
I write the solution for those who will have the same problem
There was an error on the virtual host conf file:
<Directory /var/www/html>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
I am having problem in my htaccess file. Would someone help me to identify the problem.
I actually removed the index.php in
foldername/application/config/config.php
I added this in vhost of my apache and restarted services
<VirtualHost *:80>
ServerAdmin user#mai.com
DocumentRoot "C:/server/Apache24/htdocs/foldername"
<Directory "C:/server/Apache24/htdocs/foldername">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ServerName https://foldername.com
ServerAlias https://foldername.com
ErrorLog "logs/dummy-host.example.com-error.log"
CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>
This works actually on my localhost, but when I configure the url, I added https because I need it to be in https, the htaccess doesn't work.
Here's my htaccess:
RewriteEngine On
RewriteRule ^(application) - [F,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
Thank you in advance.
after successfully installing XAMP and then typo3 on my Mac, I set up a virtual host to avoid typing long URL when working on TYPO3.
I uncommented the http.conf line dealing with http-vhosts.conf so that I could set up virtual hosts, then I added my virtual host (called typo3dev) in httpd-vhosts.conf and I finally edited my hosts file accordingly.
So far so good, BUT now the issue that I'm having is that while pointing to the BE ( with http://typo3dev/typo3/ ) works just fine (I am able to log in and have fun in there), I cannot see the Frontend:
When pointing my browser to http://typo3dev/ , I get redirected to http://typo3dev/get-started/ where I get a Page Not Found error
Looking at the server error logs in I get that
$[Thu Jun 21 12:39:20 2012] [error] [client 127.0.0.1] File does not exist: /Applications/XAMPP/htdocs/typo3/introductionpackage-4.7.1/get-started
By the way, my hosts file looks like this:
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
127.0.0.1 typo3dev
my httpd-vhosts.conf like that:
NameVirtualHost *:80
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
<VirtualHost *:80>
DocumentRoot "/Applications/XAMPP/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Applications/XAMPP/htdocs/typo3/introductionpackage-4.7.1"
ServerName typo3dev
</VirtualHost>
Thank you very much in advance for any help/ comment/ advice
Cheers
This looks like a RealURL/Apache configuration problem to me. Make sure that you allow .htaccess in your Apache configuration ...
<VirtualHost *:80>
DocumentRoot "/Applications/XAMPP/htdocs/typo3/introductionpackage-4.7.1"
ServerName typo3dev
<Directory /Applications/XAMPP/htdocs/typo3/introductionpackage-4.7.1>
AllowOverride all
Order allow,deny
allow from all
</Directory>
</VirtualHost>
... or configure the RewriteRules directly in the VirtualHost section.
<VirtualHost *:80>
DocumentRoot "/Applications/XAMPP/htdocs/typo3/introductionpackage-4.7.1"
ServerName typo3dev
<Directory /Applications/XAMPP/htdocs/typo3/introductionpackage-4.7.1>
AllowOverride None
Order allow,deny
allow from all
</Directory>
<Directory /Applications/XAMPP/htdocs/typo3/introductionpackage-4.7.1>
RewriteEngine On
RewriteRule ^/(typo3|typo3temp|typo3conf|t3lib|tslib|fileadmin|uploads|showpic\.php)$ - [L]
RewriteRule ^/(typo3|typo3temp|typo3conf|t3lib|tslib|fileadmin|uploads|showpic\.php)/.*$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* index.php [L]
</Directory>
</VirtualHost>
Remember to reload / restart Apache after making changes to the configuration.
It's seems to me like you have installed the wrong package. Install only the source package because all other package is for demo. Also if you can avoid Apache. It's complicated and bloated. I can recommend lighttpd. It's much easier to configure especially with virtual domains.