I have a website containing a directory and pages.
Let’s call the directory ‘Maintenance’ and pages ‘page1.html,…’
I want to redirect each file under the directory to query parameter such as ‘/?q=pageX’.
<VirtualHost *:80>
ServerName myServer.com
ServerAlias www.myServer.com
DocumentRoot "/var/www/html"
RewriteEngine on
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
RewriteRule ^(/Maintenance/[^/]+).html$ /?q=MyPage [R=301,L]
RewriteRule "^(.*).ht$" "index.html/?q=$1 [NC,L,QSA,CO=RewriteRule;01;https://www.myServer.com;30/;SameSite=None;Secure]"
Redirect permanent /(.*) https://%{SERVER_NAME}/$1
I’ve been trying ModeRewrite w/ various setups, read lots of ‘how to’ but nothing works for me.
Help will be most appreciated.
Thanks,
John
2
Answers
Based on your shown samples, could you please try following. Please make sure to clear your browser cache before testing your URLs.
You can use these rules in 2
VirtualHost
sections:It is important to keep rewrite rules in
VirtualHost *:443
because port 80 one is just redirecting all the traffic tohttps
.