I have a problem, let me explain.
Rewrite_module is enabled on WAMP
My host is mapped:
127.0.0.1 localhost
127.0.0.1 mydomain.com
My vhost declared on WAMP:
<VirtualHost *: 80>
ServerAdmin contact#mydomain.com
DocumentRoot "E:/wamp/www/subfolder/"
ServerName mydomain.com
ErrorLog "logs/mydomain.com.log"
CustomLog "logs/mydomain.com.log" common
<Directory "E:/wamp/www/subfolder /">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow, deny
Allow from all
</ Directory>
</ VirtualHost>
For now, no problem, mydomain.com arrives on E:/wamp/www/subfolder/
My projects are in sub folders such as E:/wamp/www/subfolder/my-project/
I have a htaccess with:
<Mod_rewrite.c IfModule>
RewriteEngine On
RewriteBase /my-project/
RewriteRule ^index\php$ - [L]
RewriteRule ^assets/css/(.*) /my-project/content/themes/assets/css/ $ 1 [QSA, L] [QSA, L]
RewriteCond% {REQUEST_FILENAME}! F
RewriteCond% {REQUEST_FILENAME}! -d
RewriteRule. /my-project/index.php [L]
</ IfModule>
My problem comes here. If I go on mydomain.com/my-project/ it comes to the site with no problem, but the css (for example) are not loaded, because the link is:
mydomain.com/content/themes/assets/css/
It should have:
mydomain.com/my-project/content/themes/assets/css/
I think the RewriteBase not working and I do not know why.
Thank you very much and sorry for my english.
I think you misunderstood the point of a Virtual Host.
You should create a Virtual Host for EACH of your projects so something like this
<VirtualHost *: 80>
ServerAdmin contact#mydomain.com
DocumentRoot "E:/wamp/www/subfolder/project1"
ServerName mydomain1.com
ErrorLog "logs/mydomain.com.log"
CustomLog "logs/mydomain.com.log" common
<Directory "E:/wamp/www/subfolder/project1">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow, deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *: 80>
ServerAdmin contact#mydomain.com
DocumentRoot "E:/wamp/www/subfolder/project2"
ServerName mydomain2.com
ErrorLog "logs/mydomain.com.log"
CustomLog "logs/mydomain.com.log" common
<Directory "E:/wamp/www/subfolder/project2">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow, deny
Allow from all
</Directory>
</VirtualHost>
This makes each project look and react like it was a single website on its own unique Apache instance and makes moving your projects to live servers more reliable.
You also do not need a .htaccess now unless this one project actually requires it.
Related
I'm running Ubuntu 20.04 lts with Apache 2. I enabled mod_rewrite, but when my rules are enabled it results in a 404 error.
This is my current (stripped down) .htaccess file and I still get a 404:
RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)(|/)$ index.php?page=$1
I've configured my virtualhost like so:
<VirtualHost *:80>
ServerName website
ServerAlias www.website
ServerAdmin webmaster#localhost
DocumentRoot /var/www/website
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/website/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
What have I done wrong? It works on IIS.
Nvm already solved it, somehow the MultiViews option was causing trouble or I made a type error.
replaced
Options Indexes FollowSymLinks MultiViews
with this
Options Indexes FollowSymLinks
And it works now
it's my first time to use laravel and config apache and I've a problem with apache document root, it doesn't change.
It always show apache homepage
I'm using a vm with virtualbox, and my conf.d file finish with this lines:
DocumentRoot "/var/www/laravel/public"
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName 192.168.56.3
#ServiceAlias www.test.laravel.com
DocumentRoot /var/www/laravel/public
</VirtualHost>
<Directory "/var/www/laravel/public">
Options FollowSymLinks
ReWriteEngine On
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</Directory>
Do you know what is wrong?
Thank you
I am using WAMP 3.06. I have a web site hosted in "c:/wamp64/www/webagenda"
When I try to access the site remotely using "http://cloudappoint.myvnc.com", I get:
Forbidden
You don't have permission to access /webagenda on this server.
Apache/2.4.23 (Win64) PHP/5.6.25 Server at agenda.myvnc.com Port 8000
My virtual host file is:
# Virtual Hosts
<VirtualHost *:8000>
ServerName localhost
DocumentRoot c:/wamp64/www
<Directory "c:/wamp64/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
#if I uncomment the next lines the problem is over
#<Directory "c:/wamp64/www/webagenda">
#Options Indexes FollowSymLinks Includes ExecCGI
#DirectoryIndex index.php
#AllowOverride None
#Require all granted
#</Directory>
<VirtualHost *:8000>
ServerName cloudappoint
ServerAlias cloudappoint.myvnc.com
DocumentRoot c:/wamp64/www/webagenda
ErrorLog "logs/agenda-error.log"
CustomLog "logs/agenda-access.log" common
<Directory "c:/wamp64/www/webagenda/">
Options +Indexes +FollowSymLinks +MultiViews
DirectoryIndex index.php
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
As you can see from my comments, if I I uncomment the next lines the problem is over:
<Directory "c:/wamp64/www/webagenda">
Options Indexes FollowSymLinks Includes ExecCGI
DirectoryIndex index.php
AllowOverride None
Require all granted
</Directory>
What is wrong here, please?
If moving the <Directory> block out of the <VirtualHost> block causes access to be allowed then it is a fair assumption that there is something wrong with the <VirtualHost> definition.
Can I suggest that you try this change in your definition
<VirtualHost *:8000>
ServerName cloudappoint.myvnc.com <--change
ServerAlias www.cloudappoint.myvnc.com <--change
DocumentRoot c:/wamp64/www/webagenda
ErrorLog "logs/agenda-error.log"
CustomLog "logs/agenda-access.log" common
<Directory "c:/wamp64/www/webagenda/">
Options +Indexes +FollowSymLinks +MultiViews
DirectoryIndex index.php
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
EDIT
I assume you are adding the non standard port number to the url when trying to access the site?
http://cloudappoint.myvnc.com:8000
When I add the :8000 I do not get the error I get an offline page saying
The site you have requested is currently unavailable,
please try back again later.
I placed my rewrite rules inside directory tag.
Before I asked the question I've read Apache documentation where is written:
A web-path to a resource
RewriteRule ^/foo$ /bar
If DocumentRoot is set to /usr/local/apache2/htdocs, then this directive would map requests for http://example.com/foo to the path /usr/local/apache2/htdocs/bar.
So I did as written.
In example below I want: /aaaaa to redirect to /index.php?action=aaaaa
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName test.com
DocumentRoot /var/www/project/released/test
<Directory /var/www/project/released/test>
AllowOverride none
Options Indexes FollowSymLinks MultiViews
Order allow,deny
allow from all
RewriteEngine on
RewriteRule ^/([a-z0-9-_]+)$ /index.php?action=$1 [NC,L]
</Directory>
</VirtualHost>
In apache log is written:
[Mon May 27 23:14:11 2013] [error] File does not exist: /var/www/project/released/test/aaaaa
Could you please help and advice why this may not work and why the log shows totally different behavior (obviously this path does not exist but it never should, according to the doc!)? I have mod_rewrite installed and enabled.
localhost/mysite/public - working
localhost/mysite/public/index.php/tasks - working
localhost/mysite/public/tasks - NOT WORKING ERROR 404
I tried almost everything and still have problem.
I have got mod rewrite on - i used : sudo a2enmod vhost_alias rewrite
and restarted the server
my .htaccess file:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
my etc/apache2/sites-avaliable/default its like:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
when I change AllowOverride to All - only "localhost/" is working but i cant run any sites like "localhost/mysite" .
I have tried to add to default file a next virtual host like:
<VirtualHost *:80>
DocumentRoot /var/www/mysite/public/
<Directory /var/www/mysite/public/>
AllowOverride All
</Directory>
</VirtualHost>
but it is not working at all.
First, if you are using Laravel 3 make sure that you have updated /application/config/application.php and made the "application index" var to a null value, like "". https://github.com/laravel/laravel/blob/master/application/config/application.php#L42
If you've already done that, try setting up a vhost. It sounds like you are using Apache 2.
First create an additional vhosts file, for example /etc/apache2/sites-available/laravel
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName laravel.dev
ServerAlias *.laravel.dev
DocumentRoot /home/kriss/projects/laravel/public
</VirtualHost>
Then update your /etc/hosts file and add
127.0.0.1 laravel.dev
Then (and this may be the step you missed before)
sudo a2ensite laravel
This will make a sim link in /etc/apache2/sites-enabled to your vhost config file.
Finally restart your server:
sudo service apache2 restart
You should be able to connect with the url http://laravel.dev, and your rewrites should be working.
Run the following command in Terminal to enable mod_rewrite.
sudo a2enmod rewrite
Now restart Apache.
sudo service apache2 restart