Simple 301 redirect using mod_alias not working - apache

I tried to redirect a page '/page-one' to '/page/one/' just using Redirect directives but it doesn't work. I tried several options but none of them make it works:
Redirect 301 /page-one /page/one/
Redirect permanent /page-one /page/one/
Redirect 301 /page-one https://www.example.com/page/one/
Please find below the whole apache2.conf file I am using in my project:
<VirtualHost xx.xxx.xx.xx:8080>
ServerName example.com
ServerAlias www.example.com
redirect / https://www.example.com/
Redirect 301 /page-one /page/one/
DocumentRoot /home/admin/web/example.com/public_html
<Directory /home/admin/web/example.com/public_html>
AllowOverride All
Options +Includes -Indexes +ExecCGI
php_admin_value open_basedir /home/admin/web/example.com/public_html:/home/admin/tmp
php_admin_value upload_tmp_dir /home/admin/tmp
php_admin_value session.save_path /home/admin/tmp
<Files *.php>
SetHandler fcgid-script
</Files>
FCGIWrapper /home/admin/web/example.com/cgi-bin/fcgi-starter .php
</Directory>
<Directory /home/admin/web/example.com/stats>
AllowOverride All
</Directory>
<Directory "/home/user1/public_html">
AllowOverride All
</Directory>
IncludeOptional /home/admin/conf/web/apache2.example.com.conf*
</VirtualHost>
Any suggestions are welcome!
Thanks!

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>

VPS Nginx/ Apache | multi website doesn't work

I've moved 2 domains on the VPS and they work fine, just one at a time.
If I disable one, then the other one works - not both.
dom1.com , dom2.com
have the same DNS records, except the A records with their domain-name pointing to the same IP on the VPS, their DNS records are both on CloudFlare, and they're both configured the same way on the VPS (with aaPanel).
The only difference is their site directory.
Do you know what could trigger this issue?
CentOS 8
aaPanel 6.8.21
Apache 2.4 (same issue on Nginx 1.19)
DNS manager: CloudFlare
Many Thanks
dom1.com | config
DocumentRoot "/www/wwwroot/dom1.com"
ServerName 745e5c8e.dom1.com
ServerAlias dom1.com mail.dom1.com
#errorDocument 404 /404.html
ErrorLog "/www/wwwlogs/dom1.com-error_log"
CustomLog "/www/wwwlogs/dom1.com-access_log" combined
#HTTP_TO_HTTPS_START
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{SERVER_PORT} !^443$
RewriteRule (.*) https://%{SERVER_NAME}$1 [L,R=301]
</IfModule>
#HTTP_TO_HTTPS_END
#referenced redirect rule, if commented, the configured redirect rule will be invalid
IncludeOptional /www/server/panel/vhost/apache/redirect/dom1.com/*.conf
#DENY FILES
<Files ~ (\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)$>
Order allow,deny
Deny from all
</Files>
#PHP
<FilesMatch \.php$>
SetHandler "proxy:unix:/tmp/php-cgi-73.sock|fcgi://localhost"
</FilesMatch>
#PATH
<Directory "/www/wwwroot/dom1.com">
SetOutputFilter DEFLATE
Options FollowSymLinks
AllowOverride All
Require all granted
DirectoryIndex index.php index.html index.htm default.php default.html default.htm
</Directory>
</VirtualHost>
<VirtualHost *:443>
ServerAdmin webmaster#example.com
DocumentRoot "/www/wwwroot/dom1.com/"
ServerName SSL.dom1.com
ServerAlias dom1.com mail.dom1.com
#errorDocument 404 /404.html
ErrorLog "/www/wwwlogs/dom1.com-error_log"
CustomLog "/www/wwwlogs/dom1.com-access_log" combined
#SSL
SSLEngine On
SSLCertificateFile /www/server/panel/vhost/cert/dom1.com/fullchain.pem
SSLCertificateKeyFile /www/server/panel/vhost/cert/dom1.com/privkey.pem
SSLCipherSuite EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5
SSLProtocol All -SSLv2 -SSLv3 -TLSv1
SSLHonorCipherOrder On
#PHP
<FilesMatch \.php$>
SetHandler "proxy:unix:/tmp/php-cgi-73.sock|fcgi://localhost"
</FilesMatch>
#DENY FILES
<Files ~ (\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)$>
Order allow,deny
Deny from all
</Files>
#PATH
<Directory "/www/wwwroot/dom1.com/">
SetOutputFilter DEFLATE
Options FollowSymLinks
AllowOverride All
Require all granted
DirectoryIndex index.php index.html index.htm default.php default.html default.htm
</Directory>
</VirtualHost>
dom2.com | config
ServerAdmin webmaster#example.com
DocumentRoot "/www/wwwroot/dom2.com"
ServerName 218ac146.dom2.com
ServerAlias dom2.com mail.dom2.com
#errorDocument 404 /404.html
ErrorLog "/www/wwwlogs/dom2.com-error_log"
CustomLog "/www/wwwlogs/dom2.com-access_log" combined
#DENY FILES
<Files ~ (\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)$>
Order allow,deny
Deny from all
</Files>
#PHP
<FilesMatch \.php$>
SetHandler "proxy:unix:/tmp/php-cgi-73.sock|fcgi://localhost"
</FilesMatch>
#PATH
<Directory "/www/wwwroot/dom2.com">
SetOutputFilter DEFLATE
Options FollowSymLinks
AllowOverride All
Require all granted
DirectoryIndex index.php index.html index.htm default.php default.html default.htm
</Directory>
</VirtualHost>
I found the problem.
aaPanel added a wrong sub-domain in their config file.
So fixing that resolved the issue.

rancid VIEWVC apache rewrite rule, CGI page incorrectly shown

i configured rancid VIEWVC web page, CentOS 8
<VirtualHost *:80>
DocumentRoot /var/www
ScriptAlias /cgi-bin/ "/var/www/cgi-bin"
ScriptAlias /viewvc /var/www/cgi-bin/viewvc.cgi
ScriptAlias /query /var/www/cgi-bin/query.cgi
<Directory "/var/www/cgi-bin">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
It works fine when accessing http://ip/viewvc
I want to access to VIEWVC page by http://ip
so i modified conf file:
<VirtualHost *:80>
DocumentRoot /var/www
ScriptAlias /cgi-bin/ "/var/www/cgi-bin"
ScriptAlias /viewvc /var/www/cgi-bin/viewvc.cgi
ScriptAlias /query /var/www/cgi-bin/query.cgi
RewriteEngine on
RewriteRule (.*) /var/www/cgi-bin/viewvc.cgi
<Directory "/var/www/cgi-bin">
AllowOverride All
Options +ExecCGI -Indexes
AddHandler cgi-script cgi py
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
with redirection, page is "partially" loaded
http://IP
Without redirection all works fine
http:/ip/viewvc
Try at least RewriteRule ^/$ instead otherwise any static assets will be rewritten to the CGI too.

Prestashop configuration multishop

i have to migrate from prestashop 1.6 to prestashop 1.7, in the new version i have made a multishop site.
how should I set the httpd.conf and the conf file of the related site for it to work?
now my conf site file is:
<VirtualHost *:80>
ServerAdmin name#example.com
ServerName www.example.it
ServerAlias example.it
DocumentRoot /home/sites/www.example.it/web/
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /home/sites/www.example.it/web/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
Require all granted
</Directory>
AddType application/x-httpd-php .php5
AddType application/x-httpd-php .php4
AddType application/x-httpd-php .php
RewriteEngine on
#RewriteCond %{HTTPS} off
#RewriteCond %{REQUEST_URI} !^/.well-known/ [NC]
#RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [NC,R=301,L]
#RewriteOptions inherit
</VirtualHost>
<VirtualHost *:443>
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateKeyFile /etc/letsencrypt/live/www.example.it/privkey.pem
SSLCertificateFile /etc/letsencrypt/live/www.example.it/cert.pem
SSLCertificateChainFile /etc/letsencrypt/live/www.example.it/chain.pem
ServerAdmin name#example.com
ServerName www.example.it
ServerAlias example.it
DocumentRoot /home/sites/www.example.it/web
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /home/sites/www.example.it/web>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
Require all granted
</Directory>
AddType application/x-httpd-php .php5
AddType application/x-httpd-php .php4
AddType application/x-httpd-php .php
Header always set Strict-Transport-Security "max-age=63072000; includeSubdomains;"
php_admin_value open_basedir "/home/sites/www.example.it:/home/sites/www.example.it/private:/home/sites/www.example.it/tmp:/tmp"
php_admin_value session.save_path "/home/sites/www.example.it/tmp"
php_admin_value upload_tmp_dir "/var/www/clients/client1/web1/tmp"
php_admin_value sendmail_path] "/usr/sbin/sendmail -t -i -f webmaster#example.it"
php_admin_value max_input_vars 10500
php_admin_value memory_limit 512M
php_admin_value max_execution_time 44000
php_admin_value upload_max_filesize 512M
RewriteEngine on
RewriteOptions inherit
<Directory /home/sites/*/web>
AllowOverride All
</Directory>
</VirtualHost>
What should I add or change in this file?
is there any other file I need to change?
thanks
You don't have to change your server's virtual host when turning on multishop option. Do you have some problems with the configuration ?

How to create an alias for phpmyadmin in apache?

Using Ubuntu 16.04, apache2.
I have the following virtual host in apache, but my URL http://example.com/phpmyadmin gives a 404 error. Any ideas?
From looking at other stackoverflow posts, this should work, but it isn't working. I'm fairly new to the Linux/Apache world (if this was on IIS I'd be fine!) so if you can give any pointers that'd also be appreciated.
<VirtualHost *:80>
ServerName example.org
Alias /phpmyadmin/ /user/share/phpmyadmin/
DocumentRoot "/var/www/html"
<Directory /usr/share/phpmyadmin>
Require all granted
Options FollowSymLinks
DirectoryIndex index.php
<IfModule mod_php5.c>
AddType application/x-httpd-php .php
php_flag magic_quotes_gpc Off
php_flag track_vars On
php_flag register_globals Off
php_admin_flag allow_url_fopen Off
php_value include_path .
php_admin_value upload_tmp_dir /var/lib/phpmyadmin/tmp
php_admin_value open_basedir /usr/share/phpmyadmin/:/etc/phpmyadmin/:/var/lib/phpmyadmin/
</IfModule>
</Directory>
# Disallow web access to directories that don't need it
<Directory /usr/share/phpmyadmin/libraries>
Order Deny,Allow
Deny from All
</Directory>
<Directory /usr/share/phpmyadmin/setup/lib>
Order Deny,Allow
Deny from All
</Directory>
<Directory "/var/www/html">
allow from all
Options None
Require all granted
</Directory>
</VirtualHost>
Thanks in advance.