The yii2-advanced template is used. After the transfer to production (using CentOS) on the files of scripts and styles I catch the error 403 That is, the page is given, and the styles are not tightened.
And if you go through a direct link (according to styles), then they are given correctly (response 200). What could be the reason?
Conf for backend
<VirtualHost *:443>
ServerName cp.tickets.site.ru
ServerAdmin osd#site.ru
DocumentRoot "/var/www/vhost/tickets.site.ru/htdocs/backend/web"
Options FollowSymLinks
DirectoryIndex index.php index.html
RewriteEngine on
<Directory "/var/www/vhost/tickets.site.ru/htdocs/backend/web">
RewriteEngine on
AllowOverride none
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward the request to index.php
RewriteRule ^ index.php [L]
</Directory>
ErrorLog /var/www/vhost/tickets.site.ru/logs/cp_http_error.log
TransferLog /var/www/vhost/tickets.site.ru/logs/cp_http_access.log
</VirtualHost>
Related
I have a Vuejs App deployed at apache2 server in digitalocean , when you hit the url it forwards you to login page which is working fine and then automatic navigate me to dashboard page that have cards when I click on one of cards I get 404 page even after I edit my .htaccess file in dist
NOTE the card route is domain.com/build
I tried .htaccess configuration from docs
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>
and here is my virtual host configuration
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin email
ServerName domain.com
ServerAlias www.domain.com
DocumentRoot /var/www/domain.com/public_html/app/dist
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
ProxyPass /api/ http://localhost:8000/
ProxyPassReverse /api/ http://localhost:8000/
RewriteEngine on
# Some rewrite rules in this file were disabled on your HTTPS site,
# because they have the potential to create redirection loops.
#RewriteCond %{SERVER_NAME} =domain.com
#RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
SSLCertificateFile /etc/letsencrypt/live/domain.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/domain.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>
Nothing wrong with virtual host file, the problem was in apache2.conf file in /etc/apache2. what I need is to change this part from
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
to :
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
you need to change the AllowOverride attribute.
after trying unsuccessfully to set up BookStack with nginx, I switched to Apache.
However, I have similar difficulties setting up the subfolder.
BookStack should be available at https://domain.name/bookstack.
The location of BookStack is /var/www/bookstack/... .
I have also added the domain in the .env.
I just figured out, that the configuration for HTTP works like expected.
<VirtualHost *:80>
ServerName domain.name
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# BookStack Configuration
Alias "/bookstack" "/var/www/bookstack/public"
<Directory "/var/www/bookstack/public">
Options FollowSymlinks
AllowOverride none
Require all granted
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]
</Directory>
<Directory "/var/www/bookstack">
AllowOverride None
Require all denied
</Directory>
# End BookStack Configuration
</VirtualHost>
But when I put in the config for HTTPS (I created a certificate with certbot/letsencrypt), I get the login page without styles. As I log in, it takes me to HTTP-domain with error 404 Not found.
Here's my current SSL config:
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName domainname
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# BookStack Configuration
Alias "/bookstack" "/var/www/bookstack/public"
<Directory "/var/www/bookstack/public">
Options FollowSymlinks
AllowOverride none
Require all granted
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]
</Directory>
<Directory "/var/www/bookstack">
AllowOverride None
Require all denied
</Directory>
# End BookStack Configuration
SSLEngine on
SSLCertificateFile /path/to/certificate/file
SSLCertificateKeyFile /path/to/certificate/key/file
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
I don't get the problem with this.
I created a virtual host with this code :
<VirtualHost *:80>
ServerAdmin admin#127.0.0.1
ServerName site.ws
ServerAlias www.site.ws
DocumentRoot /home/me/Projects/website/build
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /home/me/Projects/website/build>
Allow from all
Satisfy any
</Directory>
</VirtualHost>
and I created a .htaccess file in my /build directory with this code :
RewriteEngine On
RewriteRule ^(.*)$ $1.html [R,NC]
Consider my mod_rewrite is active in apache2, but I can't open pages with /filename
e.g site.ws/about
It shows error :
The requested URL /about was not found on this server.
I try this with Apache2 2.4.27 in win:
First enable vhost in httpd.conf file.
vhost:
<VirtualHost *:80>
ServerName site.ws
DocumentRoot /home/me/Projects/website/build
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /home/me/Projects/website/build>
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
.htaccess:
###START MOD_REWRITE
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#REMOVE .html EXTENSION
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.html [NC,L]
</IfModule>
###END MOD_REWRITE
i solved this problem with :
RewriteEngine On
RewriteRule ^([a-zA-Z-]+)$ $1.html [L,NC]
I'm new to Phalcon and I like the framework but I have problems with links. I use phalcon version 0.6.1 and XAMPP 1.8.1 that has vhosts set to xampp/htdocs/test where my phalcon test is.
I have been following the tutorial and came to a problem. When I use links to load other controllers the adress bar shows the correct path but as far as I can see the index.phtml get loaded every time. I uploaded the files here so you can see for yourselves.
It doesn't matter if I use Tag::LinkTo() or since it doesn't change.
edit:
I followed the instructions, removed the .htaccess files from the /test and /test/public directories to move the to httpd.conf. At the end of it I added
<Directory "C:/xampp/htdocs/www/test">
RewriteEngine on
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
</Directory>
<Directory "C:/xampp/htdocs/www/test/public">
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?_url=/$1 [QSA,L]
</Directory>
and modified my httpd-vhosts.conf like this
ServerAdmin admin#example.host
DocumentRoot "C:/xampp/htdocs/test/public"
DirectoryIndex index.php
ServerName example.host
ServerAlias www.example.host
<Directory "C:/xampp/htdocs/test/public">
Options All
AllowOverride All
Allow from all
</Directory>
The page loads but the absolute links like /public/css/bootstrap.min.css don't work and when I click the link it gives me an error 404 and says Object not found. I modified the files like this:
<Directory "C:/xampp/htdocs/test">
RewriteEngine on
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
</Directory>
<Directory "C:/xampp/htdocs/test/public">
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?_url=/$1 [QSA,L]
</Directory>
and
ServerAdmin admin#example.host
DocumentRoot "C:/xampp/htdocs/test"
DirectoryIndex index.php
ServerName example.host
ServerAlias www.example.host
<Directory "C:/xampp/htdocs/test">
Options All
AllowOverride All
Allow from all
</Directory>
But that brings me to my original problem that when I click the link it loads index.phtml again even though it says localhost:8005/sample in the URL.
It looks like your Apache configuration is not allowing reading the .htaccess file:
<VirtualHost *:80>
ServerAdmin admin#localhost
ServerName phalcon.test
DocumentRoot /srv/htdocs/sites/test
<Directory "/srv/htdocs/sites/test">
AllowOverride All
Options All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Also, at the top of your public/index.php check that $_GET['_url'] has the URI passed to your browser
I wanted to move my .htaccess file - redirects into my vhost conf file...
This was working - but the htaccess redirects were not...
<VirtualHost *:80>
ServerName dev.x.com
ServerAlias dev.x.com
DocumentRoot "C:/wwwroot/x"
Alias /modules/ "C:/wwwroot/x/_my_modules/"
ErrorLog "C:/wwwroot/x/_my_logs/error.log"
CustomLog "C:/wwwroot/x/_my_logs/access.log" combined
<Directory "C:/wwwroot/x/_my_logs/" >
Options FollowSymLinks
AllowOverride All
Order deny,allow
Deny from all
Satisfy all
</Directory>
</VirtualHost>
Then i did this -
<VirtualHost *:80>
ServerName dev.x.com
ServerAlias dev.x.com
DocumentRoot "C:/wwwroot/x"
Alias /modules/ "C:/wwwroot/x/_my_modules/"
ErrorLog "C:/wwwroot/x/_my_logs/error.log"
CustomLog "C:/wwwroot/x/_my_logs/access.log" combined
<Directory "C:/wwwroot/x/_my_logs/" >
Options FollowSymLinks
AllowOverride All
Order deny,allow
Deny from all
Satisfy all
</Directory>
RewriteEngine on
# if requested URI is not a file and not a directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# externally redirect to /newLocation/{URI}
# RewriteRule (.*) index.php?_req=$1 [L]
# could use a redirect to a new directory ---
RewriteRule ^ /_mf_modules%{REQUEST_URI} [L,R=301]
</VirtualHost>
My objective was this:
I wanted any "directory" request - that didn't exist - to be rerouted to a directory of that name in the _my_modules dir.
IF a file did not exist I wanted to redirect to the to a directory of that name in the _my_modules dir.
So if www.x.com/xxx was the url... and 'xxx' dir didn't exist, I'd redirect to www.x.com/_my_modules/xxx
and like wise if www.x.com/xxx.php was requested - but xxx.php DIDN'T exist, they wou be redirected to www.x.com/_my_modules/xxx
however (even though there is an index.php in each dir) these always results in th eURL redirecting to this...
The requested URL /modules/modules/modules/modules/modules/modules/modules/modules/modules/modules/modules/modules/modules/modules/modules/modules/modules/modules/modules/_my_modules/ was not found on this server.
So I got fed up and changed the vhost file back to what I had to begin with, restarted Apache, and it's still redirecting, I can't get rid of the behavior.
You can move the RewriteRules from a .htaccess to the VirtualHost environment by putting them in a <Directory> environment in your vhost configuration.
In your case, try to cut and paste your rewrite rules in <Directory "C:/wwwroot/x/_my_logs/" >
If you really want to put them in the VirtualHost environment, you have to modify the paths in them: RewriteRules in .htaccess or are relative to the directory, RewriteRules in the VirtualHost are absolute to the root of the filesystem or the DocumentRoot.
rewritecond example:
RewriteCond %{REQUEST_FILENAME} !-f
should be in vhost:
RewriteCond /your/documentroot/%{REQUEST_FILENAME} !-f
rewriterule example:
RewriteRule (.*) /your/documentroot/index.php?_req=$1 [L]
should be in vhost:
RewriteRule (.*) index.php?_req=$1 [L]