1) Avoid rewriting from <Directory> or <Location> blocks. 2) Avoid using mod_alias (redirect) from that context as well 3) Provide more than one rewrite log line, context matters 4) This can be replaced with FallbackResource /index.php:
RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?q=$1 [L,QSA] 5) Why are you using mod_rewrite, either way? On Wed, May 3, 2023 at 6:40 PM Jim Weill <moon...@icsi.berkeley.edu> wrote: > The logs say something of the form: input=full.website.base.URL > pattern=hostname.fq.dn not matched > > Where am I going wrong here? > > jim > > On Wed, May 3, 2023 at 9:55 AM Jim Weill <moon...@icsi.berkeley.edu> > wrote: > >> We have a website that has been in use for a project for years, which >> someone else took up and would like the site permanently redirected to the >> new URL. For whatever reason I cannot get this redirect to work >> consistently, and I'd like to know where I'm going wrong. >> >> The only thing I changed on the website.conf file was adding the redirect >> statement. What used to happen was if you came in on the full base URL, it >> would append the directory to the URL and load the site. >> >> Now it alternates between showing the /var/www/index file or redirecting >> to the new website, and I'm not sure why. >> >> website.conf: >> RewriteEngine On >> RewriteCond %{HTTP_HOST} ^full.website.base.URL$ [NC] >> RewriteRule ^/$ https://full.website.base.URL/url-path/ [L,R] >> alias /url-path "/local/www/path" >> <Directory "/local/www/path"> >> Require all granted >> RewriteEngine on >> RewriteBase /url-path >> Redirect permanent https://new.website.base.url/ >> RewriteCond %{REQUEST_FILENAME} !-f >> RewriteCond %{REQUEST_FILENAME} !-d >> RewriteRule ^(.*)$ index.php?q=$1 [L,QSA] >> RewriteCond %{HTTPS} off >> RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} >> RewriteCond %{HTTP_HOST} !full.website.base.URL >> RewriteRule ^.*$ https://full.website.base.URL%{REQUEST_URI} [R] >> <Files "cron.php"> >> RewriteCond %{REQUEST_URI} /url-path/cron.php$ [NC] >> RewriteRule "^/url-path/cron.php$" >> http://full.website.base.URL%{REQUEST_URI} [L] >> </Files> >> </Directory> >> >> >> and for good measure, I put .htaccess in the local www path: >> RewriteEngine On >> Redirect permanent https://new.website.base.url/ >> >> >>