1

I have 2 .htacces file

  1. /usr/local/apache2/htdocs .htacess file with
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteCond %{REQUEST_URI} !^/test2/
RewriteRule ^(.*)$ /test2/$1 [NC,QSA]
  1. /usr/local/apache2/htdocs/test2 .htacess file with
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
RewriteRule !^(ui/|index.php|favicon.ico) - [F,L,NC]
#RewriteCond %{HTTPS} off
#RewriteCond %{REQUEST_URI} !^/admin
#RewriteRule .* https://%{HTTP_HOST}%/admin [L,R=301]
</IfModule>

The application will force the application to the url below while hiding the index.php

http://www.example.com/admin additionally there is another link with http://www.example.com/display

default directory configured in httpd.conf are :

DocumentRoot "/usr/local/apache2/htdocs/test2"
<Directory "/usr/local/apache2/htdocs/test2"

However if I try to run with https the link https://www.example.com/admin

I will get this error :

Forbidden
You don't have permission to access /admin/ on this server.

I have tried using the #commented code and still has error. Please help

Amin Afip
  • 23
  • 4
  • It looks like you've perhaps not configured the `` (ie. HTTPS) container in the server config? See this related question: https://stackoverflow.com/questions/66512324/wordpress-htaccess-acting-weird – MrWhite Mar 10 '21 at 13:19
  • You have HTTPS turned off so it will by no means work. turn it on `RewriteCond %{HTTPS} !on` Or take it out entirely – mw509 Mar 10 '21 at 13:31
  • @mrwhite https was configured. After further checking found out there are two problems , fixing those fix my problem 1. I had another ssl.conf with a different document root 2. The Order allow,deny already depreciated in Apache 2.4 . Change a file php.conf it to# Depreciated in Apache 2.2 # Order allow,deny # Deny from all # Satisfy All # New in Apache 2.4 Require valid-user Require ip 127.0.0.1 https://stackoverflow.com/questions/21551840/forbidden-you-dont-have-permission-to-access-on-this-server – Amin Afip Mar 11 '21 at 02:11
  • @AminAfip Thanks for the feedback. You should add that as an "answer" (and accept it) to help other readers. Thanks. – MrWhite Mar 11 '21 at 09:45

1 Answers1

1

These problem were fix by applying

  1. I have found out that there are another file, ssl.conf that has a DocumentRoot, fix the problem via adding the same document root in ssl.conf
DocumentRoot "/usr/local/apache2/htdocs/test2"
<Directory "/usr/local/apache2/htdocs/test2"

and

  1. Change a file php.conf to (# was the old code)
# Depreciated in Apache 2.2 
# Order allow,deny 
# Deny from all 
# Satisfy All 
# New in Apache 2.4 
<RequireAll> 
Require valid-user Require ip 127.0.0.1 
</RequireAll> 
Amin Afip
  • 23
  • 4