I have an issue with my apache config.
I just set a new windows server with Apache2.4 and SSL certificate but when i want to access to my https://localhost, i have a 403 Forbidden error.
This is my vhost-myproject.conf
<VirtualHost *:443>
DocumentRoot "D:/www/myproject/public"
SetEnv APPLICATION_ENV "production"
SetEnv ZF2_PATH D:/zend/ZendFramework-2.4.13/library
ServerName myproject.fr
<Directory "D:/www/myproject/public">
Options +ExecCGI +FollowSymLinks
DirectoryIndex index.php
AllowOverride All
Require all granted
</Directory>
SSLEngine on
SSLCertificateFile "D:/mycertificate.crt"
SSLCertificateKeyFile "D:/mykey.key"
</VirtualHost>
And this is my .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L]
</IfModule>
And my hosts
127.0.0.1 localhost myprojet.fr
ip_server myprojet.fr localhost
Thank you for your help.
Check your httpd.conf file, and make sure that parameters "Listen" and "ServerName" are configured like "Listen 80" and "ServerName localhost:80".
Related
Good morning,
I’m currently using Cakephp 3 version to develop an application. It should be online on an Ubuntu server and through the subdomain: http://etraining.minmap.cm
To do this, I configured a virtualHost, with the content :
<VirtualHost *:80>
ServerName etraining.minmap.cm
ServerAlias www.etraining.minmap.cm
ServerAdmin webmaster#localhost
DocumentRoot /var/www/etraining.minmap.cm/public_html/webroot
<Directory /var/www/etraining.minmap.cm/public_html/webroot>
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
The content of the .htaccess located at the application folder is:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^(\.well-known/.*)$ $1 [L]
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
The content of the .htaccess located at webroot directory is:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
I have followed all the configuration steps outlined in the official documentation.
mod_rewrite is enabled, mbstring and intl extensions are also enabled
But, I have 500 Internal Server Error:
This is the error reported in my Apache error.log:
I don’t know if I misconfigured Apache, my .htaccess files, and/or the config/app.php?
You should enable apache re-write module. It will work
"sudo a2enmod rewrite"
"sudo service apache2 restart"
Update .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
I'm trying to setup my apache configuration file with my slim framework application to use ssl. I've done this in the past but for whatever reason, I'm getting 404 errors when I try to access any page other than the home page. Here is my apache configuration file:
<VirtualHost *:80>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI}
RewriteCond %{SERVER_NAME} =www.my-site.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
ServerAdmin my.email#gmail.com
ServerName www.my-site.com
</VirtualHost>
<VirtualHost *:443>
SSLEngine on
SSLCertificateFile /path/to/cert.pem
SSLCertificateKeyFile /path/to/privkey.pem
ServerAdmin my.email#gmail.com
DocumentRoot /wwwroot/sites/my-site/public
ServerName www.my-site.com
ErrorLog logs/www.my-site.com-error_log
CustomLog logs/www.my-site.com-access_log common
<Directory "/wwwroot/sites/my-site/public">
AllowOverride All
RewriteEngine On
RewriteBase /wwwroot/sites/my-site/public
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
</Directory>
</VirtualHost>
As stated, my home page works exactly as I'd expect it to work. But when I try to go to https://www.my-site.com/another/page, I get a 404 error.
I have a dev version of this project set up on another server that doesn't use https and I have no problems going to http://dev.my-site.com/another/page.
try set RewriteBase to /
<Directory "/wwwroot/sites/my-site/public">
AllowOverride All
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
</Directory>
I'm using vuejs with mode history enabled, and on the docs I find this Histoy mode docs
but then using Let's Encrypt with certbot I run a command to generate an ssl certificate, but now because of the redirection the following configuration no longer works.
<VirtualHost *:80>
ServerName virtuafest.vir.mx
ServerAdmin webmaster#localhost
DocumentRoot /var/www/virtuafest17/dist
<Directory /var/www/virtuafest17/dist>
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>
</Directory>
RewriteEngine on
RewriteCond %{SERVER_NAME} =virtuafest.vir.mx
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
How can I solve this without having to create an .htaccess file for the Rewrite conf?
Locate VirtualHost: *:443 in etc/apache2/apache2-le-ssl.conf and add your mod_rewrite there.
Hi im configuring a server in CentOS 6.5 with apache 2.4 and PHP 5.5
I install an SSL certificate and all go fine.
in another server i did the http to https redirect on htaccess file.
i meke test with that in my new server and didnt work, here are my configuration:
My .htaccess:
<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
RewriteCond %{REQUEST_URI} !/phpmyadmin/.*
RewriteCond %{REQUEST_URI} !/phpMyAdmin/.*
RewriteRule ^ index.php [L]
</IfModule>
My virtual host file:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName subdomain.domain.com
ServerAlias www.subdomain.domain.com
DocumentRoot /var/www/laravel-project-namel/public
<Directory /var/www/laravel-project-namel/public>
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*)
RewriteRule ^.*$ https://%1/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
</Directory>
</VirtualHost>
NameVirtualHost *:443
<VirtualHost *:443>
SSLEngine on
SSLProtocol all -SSLv2
SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW
SSLCertificateFile /etc/pki/tls/certs/cert-valido_clientes_databyte_cl.crt
SSLCertificateKeyFile /etc/pki/tls/certs/cert-valido-private.key
SSLCertificateChainFile /etc/pki/tls/certs/cert-valido_clientes_databyte_cl.pem
ServerName subdomain.domain.com
ServerAlias www.subdomain.domain.com
DocumentRoot /var/www/laravel-project-namel/public
<Directory /var/www/laravel-project-namel/public>
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
</Directory>
</VirtualHost>
i replace the domain and the folder to generic names, but all other are true.
(sorry about my english)
i did search and test every solution i found, but my site refuse to redirect.
Problem is you're not capturing the URI in patter and using $1, %1 as back-reference.
Try this rule in your root .htaccess as very first rule:
RewriteCond %{HTTP_HOST} ^www\. [OR]
RewriteCond %{HTTPS} off
RewriteRule ^ https://domain.com%{REQUEST_URI} [R=301,L,NE]
How does one set up Symfony2 to work on Apache (Apache 2.4) combined with php-fpm?
The aim is to get rid of the .htaccess files and move everything into the apache config.
Without worrying about PHP-FPM, the config looks something like this:
<VirtualHost *:80>
ServerName mysymfonyproject.com
ServerAlias www.mysymfonyproject.com
ErrorLog /path/to/logs/mysymfonyproject_error.log
CustomLog /path/to/logs/mysymfonyproject_access.log combined
DocumentRoot "/path/to/sites/mysymfonyproject/web"
<Directory "/path/to/sites/mysymfonyproject/web">
AllowOverride None
Require all granted
## Start directives copied from standard Sf .htaccess
DirectoryIndex app.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^app\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_URI} .*\.php
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule .? - [L]
RewriteRule .? %{ENV:BASE}/app.php [L]
</IfModule>
## End directives copied from standard Sf .htaccess
</Directory>
</VirtualHost>
This thread is for me to post my own findings (and perhaps be corrected if I got it wrong!).
I prefer to just use ProxyPassMatch to make this work. By using this method, your rewrite rules in .htaccess don't need to be changed.
Here is my Apache2 vhost file:
<VirtualHost 192.168.100.51:80>
ServerName grae.labs.brainglove.com
ServerAlias www.grae.labs.brainglove.com
DocumentRoot /srv/symfony2/2.4.4/grae/web
DirectoryIndex app_dev.php
ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9001/srv/symfony2/2.4.4/grae/web/$1
<Directory /srv/symfony2/2.4.4/grae/web>
AllowOverride All
Options FollowSymLinks
Require all granted
</Directory>
ErrorLog /var/log/httpd/grae.labs.brainglove.com_error.log
CustomLog /var/log/httpd/grae.labs.brainglove.com_access.log combined
The only line you need to add is the ProxyPassMatch. Everything else stays the same.
Don't forget to change the IP address and path to your symfony2 web directory.
To pass a request through to PHPFPM, the suggested RewriteRule was:
RewriteRule ^(.*\.php(/.*)?)$ fcgi://uds=%2fpath%2fto%2fwww.sock/%{REQUEST_FILENAME} [P,END]
Here's what I ended up. It seems to be working so far, but perhaps there's a better way?
<VirtualHost *:80>
ServerName mysymfonyproject.com
ServerAlias www.mysymfonyproject.com
ErrorLog /path/to/logs/mysymfonyproject_error.log
CustomLog /path/to/logs/mysymfonyproject_access.log combined
DocumentRoot "/path/to/sites/mysymfonyproject/web"
<Directory "/path/to/sites/mysymfonyproject/web">
AllowOverride None
Require all granted
## Start directives copied from standard Sf .htaccess
DirectoryIndex app.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^app\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_URI} .*\.php
# Need to add the phpfpm call here so that php files (including app_dev.php) are passed to FPM
RewriteRule ^(.*\.php(/.*)?)$ fcgi://uds=%2fpath%2to%2fwww.sock/%{REQUEST_FILENAME} [P,END]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule .? - [L]
RewriteRule .? %{ENV:BASE}/app.php [L]
# The main phpfpm call is added at the end to pass php requests through to FPM
RewriteRule ^(.*\.php(/.*)?)$ fcgi://uds=%2fpath%2to%2fwww.sock/%{REQUEST_FILENAME} [P,END]
</IfModule>
## End directives copied from standard Sf .htaccess
</Directory>
</VirtualHost>