Htaccess issue with RewriteOptions InheritBefore - apache

I have got two htaccess:
api/public/.htaccess
RewriteRule . index.php
api/public/cron/web/.htaccess
RewriteEngine On
RewriteOptions InheritBefore
I set my vhost for cron:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName cron.api.local
ServerAlias www.cron.api.local
DocumentRoot /var/www/api/public/cron/web
ErrorLog ${APACHE_LOG_DIR}/api_cron_error.log
CustomLog ${APACHE_LOG_DIR}/api_cron_access.log combined
<Directory "/var/www/api/public/cron/web">
Options Indexes FollowSymLinks MultiViews
Require all granted
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
Url http://cron.api.local/up returns 404 status but when i replace RewriteOptions InheritBefore with RewriteRule . index.php then it works. What is wrong?
I use apache 2.4.18 and ubuntu 16.04.

To fix this issue follow this:
sudo nano /etc/apache2/apache2.conf
Find:
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted </Directory>
Replace With:
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Exit and save and restart apache with command
sudo systemctl restart apache2
Reverence:
Apache mod_rewrite is enable on server but not working?

Related

apache httpd is automatically redirecting to https

Server is running on RHEL 7.9, httpd 2.4.6 and I have the following structure in my /var/www/html directory:
/site
index.php
I can reach the root index.php by visiting the IP address. However, when I try to access content inside /site directory, it automatically switches to https, hence the content does not load.
Some snippets from /etc/httpd/conf/httpd.conf:
DocumentRoot "/var/www/html"
<Directory />
AllowOverride None
Require all denied
Options -Indexes +FollowSymLinks
</Directory>
<Directory "/var/www/html">
AllowOverride All
Options -Indexes +FollowSymLinks
Require all granted
</Directory>
<Directory "/var/www/html">
Options -Indexes +FollowSymLinks
AllowOverride All
Require all granted
</Directory>
AccessFileName .htaccess
<IfModule dir_module>
DirectoryIndex index.php index.htm index.html
</IfModule>
<Files ".ht*">
Require all denied
</Files>
IncludeOptional conf.d/*.conf
I have a virtual host setup for /etc/httpd/conf.d/site.conf
<VirtualHost <server ip>:80>
ServerAdmin webmaster#sitename.com
DocumentRoot /var/www/html/site/
ServerName www.sitename.com
ServerAlias sitename
<Directory /var/www/html/site>
Require all granted
</Directory>
</VirtualHost>

apache2 is throwing internal server error 500 after AllowOverride All, localhost

i am new in configuring server. For now, i have to configure localhost with LAMP and opencart framework. But still it is throwing internal server error 500.
Even I have tried the following things
sudo a2enmode rewrite
apache2ctl configtest // for syantax
apache2ctl -t // for syntax
/etc/apache2/sites-available/000-default.conf file
ServerName localhost
ServerAdmin webmaster#localhost
DocumentRoot /var/www/
<Directory "/var/www/">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
/etc/apache2/apache2.conf
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
/var/www/opencart/.htaccess
Options +FollowSymLinks
Header add Access-Control-Allow-Origin "*"
RewriteEngine On
RewriteBase /ot
RewriteCond $1 !^(robots\.txt)
After checking the logs, i have found invalid parameters headers. Therfore for this we have to this:
sudo a2enmode headers

Apache Symfony Vitrual Host

I clone project in /home/ivan/host/name/web and create virtual host. a2ensite and reload and restart server.
<VirtualHost *:80>
ServerName name.local
DocumentRoot /home/ivan/host/name/web
DirectoryIndex app.php
ErrorLog /var/log/apache2/name-error.log
CustomLog /var/log/apache2/name-access.log combined
<Directory "/home/ivan/host/name/web">
AllowOverride All
Allow from All
</Directory>
and hosts
127.0.0.1 name.local
but have
Forbidden
You don't have permission to access / on this server.
I doing chmod 777 -R host/ but still have error
what I'am doing wrong ?
SOLVED
<VirtualHost *:80>
ServerName aog.local
DocumentRoot /home/ivan/host/name/web
DirectoryIndex app.php
ErrorLog /var/log/apache2/name-error.log
CustomLog /var/log/apache2/name-access.log combined
<Directory "/home/ivan/host/name/web">
AllowOverride All
Require all granted
Allow from All
</Directory>
Look like you are using apache 2.4,
add directive Require all granted as shown below:
<Directory /home/ivan/host/name/web>
AllowOverride All
Options +FollowSymlinks
Require all granted
</Directory>

Forbidden 403 error when running apache

I am trying to set up a rails app(redmine) on Ubuntu 14.10 running apache2.
log
Cannot server Directory: No matching DirectoryIndex
(index.html,index.cgi,index.pl,index.php,index.xhtml,index.htm) found,
and server-generated directory index forbidden by Options directive
host.confg
<VirtualHost *:80>
ServerAdmin kanishka#thewolf.in
ServerName app.in
ServerAlias app.in
DocumentRoot /var/www/app.in/public_html/
ErrorLog /var/www/app.in/log/error.log
CustomLog /var/www/tribeapp.in/access.log combined
<Directory /var/www/app.in/public_html/redmine/public>
Options Indexes FollowSymLinks MultiViews
Require all granted
RailsBaseURI /redmine
PassengerResolveSymlinksInDocumentRoot on
Order allow,deny
allow from all
AllowOverride all
</Directory>
</VirtualHost>
New to rails. Let me know if you need more info.
Try this
Options All <--turn on all options
Options Indexes FollowSymLinks <--- replace previously set options with these two

Vhosts not redirecting

I have a server running Ubuntu 14.04 LTS and I am trying to set up vhosts. What I did already is,
1) Created 2 files desktopia.be.conf and everybodycreative.be.conf which look like this
desktopia.be.conf:
<VirtualHost *:80>
ServerAdmin your_email_address
ServerName desktopia.be
ServerAlias www.desktopia.be
DocumentRoot /var/www/desktopia
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/desktopia>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
</VirtualHost>
everybodycreative.be.conf:
<VirtualHost *:80>
ServerAdmin your_email_address
ServerName everybodycreative.be
ServerAlias www.everybodycreative.be
DocumentRoot /var/www/everybodycreative
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/everybodycreative>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
Under the www folder, I made 2 folders named desktopia and everybodycreative.
After I did that, I ran the following commands
sudo a2ensite desktopia.be
sudo a2ensite everybodycreative.be
and restarted the apache2 service.
Now the problem is that when I connect on one of the 2 domain names, I just get to see the content of my www folder as you can see here http://desktopia.be/
If anyone can tell me where I should look or what more information is needed to fix this problem, please ask me so that I can fix this. This has been bothering me for a few days already and I need this fixed asap.
Thanks for helping me already :)
I think you'll need to run
a2enmod rewrite
to turn on rewrite module.
Then in the relative folder .htaccess
RewriteCond %{HTTP_HOST} ^(.+)\.desktopia\.be
RewriteCond %{HTTP_HOST} !^www\.desktopia\.be [NC]
RewriteRule ^(.+)$ /var/www/desktopia/%1/$1
same for other url,
I haven't tried it so you may need to modify something in the .htaccess folder code
You need to enable the NameVirtualHosts directive in your config.