It seems that pretty URLs are not working for me. I have tried every thing I know, when you try http://wasamar.com.ng/login it gives a response of 404 Not Found but http://wasamar.com.ng/inde.php/login is ok, I have edited my public/ directory's .htaccess file to this:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
This is the /etc/apache2/sites-available/000-default.conf
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
ServerName wasamar.com.ng
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html/wasamar/public
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
What am I doing wrong?
It's probably because your apache rewrite module is not enabled. To enable the rewrite module on a Ubuntu machine:
sudo a2enmod rewrite
sudo service apache2 restart
If a2enmod is not available on your platform, you need to open up your httpd.conf file and uncomment the line including rewrite_module. That's something like this on a macOS machine:
LoadModule rewrite_module libexec/mod_rewrite.so
Then you need to restart the service.
Also, for htaccess files to be effective you need to set AllowOverride directive to All. Here's an example:
<Directory "/absolute/path/to/webserver/root">
# ...
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# AllowOverride FileInfo AuthConfig Limit
#
AllowOverride All
# ...
</Directory>
thanks everyone for the support but i saw my error, in the /etc/apache2/apache2.conf file i did not add the AllowOverride All section the dirctory tags, when i fixed that it worked.
Related
I'm trying to make my php server a Symfony server.
I've installed Symfony and I've created a project in /var/www/project_name
If i make server:run my_local_ip:8000 the server run correctly and I can reach it also from a computer on another net with: http://public_ip:8000, instead, if I write http://public_ip it goes on my index.php.
Well, now, I'ld like that if I write http://public_ip it goes on http://public_ip:8000 or atleast if could make Symfony run on port 80 or make Symfony run on php built-in server.
I've tried to create a virtual host, I've created this file:
project_name.conf
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
ServerName project_name
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
RewriteRule .* - [F]
</IfModule>
DocumentRoot /var/www/project_name
<Directory /var/www/project_name>
Options Indexes FollowSymlinks Multiviews
AllowOverride All
Require all granted
</Directory>
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
But it doesn't work and if I write http://public_ip it runs always my index.php.
Can you give me an help?
Completed Solution - Thanks to #Alberto Fecchi answer:
Edit 00-default.conf
Paste what you found on Alberto Fecchi's answer and also add this
#IT NEEDS "<" BEFORE TAG
Directory /var/www/tcgfiga/web/bundles>
IfModule mod_rewrite.c>
RewriteEngine Off
</IfModule>
/Directory>
Then make "sudo service apache2 restart". Sometimes it is necessary, sometimes not
Go into folder "/var/www/project/web/" and search ".htaccess" file
You should delete it, but if so your application doesn't run and you see and page with the content of the folder, recreate it and open it. You have to search
<IfModule !mod_rewrite.c>
<IfModule mod_alias.c>
# When mod_rewrite is not available, we instruct a temporary redirect of
# the start page to the front controller explicitly so that the website
# and the generated links can still be used.
RedirectMatch 302 ^/$ /app.php/
# RedirectTemp cannot be used instead
</IfModule>
</IfModule>
Comment the line RedirectMatch 302 ^/$ /app.php/
Now it works :)
Use this Virtual Host:
<VirtualHost *:80>
ServerName project_name
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
RewriteRule .* - [F]
</IfModule>
DocumentRoot /var/www/project_name/web
<Directory /var/www/project_name/web>
Options Indexes FollowSymlinks Multiviews
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Enable it with sudo a2ensite project_name and restart with sudo service apache2 restart (commands could be different on various OS).
Now you can visit http://public_ip to see your "production" application.
Hello Everyone I am working on my project which in on Laravel 5.2. I have setup my project on my local machine but its now working without adding index.php in url.
I request with the url :-
http://localhost/project_folder/admin
While I am trying to run without index.php and run my url it gives me following error.
Not Found
The requested URL /project_folder/admin was not found on this server.
For this I did following steps :
1) Give permission (777) to storage and cache folder.
2) I Go to path /etc/apache2/sites-available/000-default.conf and edit it, now it look something like this.
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
In my .htaccess file have following code.
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule ^(.*)/$ /$1 [L,R=301]
RewriteRule ^(.*)/$ /moduleTesting/$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
Please suggest me if I forget any requirement or anything else.
please enable mode rewrite.
Please ensure that you have mod rewrite enable on your system.(search for mod_rewrite in info.php having code)
<?php
phpinfo();
?>
in terminal run command:
$ sudo a2enmod rewrite
I've been trying to install a wordpress blog on an apache virtualhost for several days now to no avail. Note, the virtual host configuration works just fine, as each virtual host loads up its respective index.html or index.php. Only on a Wordpress install do I get no response. My conf file looks like
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
ServerName example.com
ServerAlias www.example.com
ServerAdmin admin#example.com
DocumentRoot /var/www/example
<Directory /var/www/example/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
The blog is located in directory /var/www/example and my .htaccess file looks like
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
I have mod_rewrite enabled, so I'm not sure what the issue is. Checking the apache error log turns up nothing and the access logs always show a return of 301. Any ideas?
I fixed this by deleting the .htaccess in the /var/www/example directory and removing the lines in the conf file.
Today I uploaded my Zend Framework 1 web project to my web server (debian) with apache2 running on it.
I developed the project on a mac with XAMPP.
I copied the configuration to the vhost and .htaccess-file.
vhost (/etc/apache2/sites-available/***.***.de.conf)
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
ServerName ****.****.de
ServerAdmin ******#******.com
DocumentRoot /var/www/****.****.de/public_html
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
SetEnv APPLICATION_ENV "development"
<Directory /var/www/****.****.de/public_html>
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
.htaccess (in public_html)
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
This is what I got from many different sources and after searching for hours this worked for my local development environment. When I open the website, I can see the start page. But controller calls do not work (except the index controller). I always get the error "Not Found".
In /etc/apache2/ports.conf I added
NameVirtualHost *:80
Of course I've added the website via a2ensite and restarted the apache2 web server.
Can someone help me please?
So after recognizing that the .htaccess is not even working (by simply setting a redirect to any domain) I found the solution:
Open /etc/apache2/apache2.conf and edit the directory setting for /var/www as following:
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Restart apache
service apache2 reload
I'm not sure if this is a good solution, but for me it works.
Mates,
I've been looking arround but still couldn't find the solution.
I have this on apache2.conf
<Directory /home/pablo/htdocs/elementalguru/cuentas/idpetecuador.com/www/system/public>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
This on 000-default.conf
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
# ServerName localhost
ServerAdmin webmaster#localhost
DocumentRoot /home/pablo/htdocs
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/home/pablo/htdocs/elementalguru/cuentas/idpetecuador.com/www/system/public"
ServerName eguru.idpet.sys
</VirtualHost>
And the .htaccess file on public folder is like this:
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
But still when I try to access a url like
http://eguru.idpet.sys/clinicas
Which is stated in hosts file.
I get a 404 error message.
Any idea why?
Thanks in advance!
Is your mod_rewrite enabled?
Try $ a2enmod rewrite and then restart apache.
Here is the laravel/laravel .htaccess, have you tried this?
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>