I use a custom php script (php v.7) and have 5 php pages:
index.php, product1.php, product2.php, product3.php, admin.php.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com$
RewriteRule (.*) https://www.example.com/$1 [R=301,L]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^(.+?)\.php$ /$1.html [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+?)\.html$ /$1.php [L]
</IfModule>
<FilesMatch ".(ico|css|jpeg|png|woff|woff2|webp)$">
Header set Cache-Control "max-age=604800, public, no-cache"
</FilesMatch>
Options -Indexes
This htaccess code redirects non-www to www, http to https and php pages redirect to .html format.
Question: how can I redirect from php to html only on 4 of the 5 pages, to add an ignore rule for admin.php?
I don’t want to have php to html redirection for the admin.php page
Thank you in advance!
I tried more than 15 variants and none of them worked in 4 hours of searching on stackoverflow
>Solution :
You can add RewriteCond %{REQUEST_URI} !^/admin.php$
before RewriteRule
to ignore admin.php
page
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com$
RewriteRule (.*) https://www.example.com/$1 [R=301,L]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{REQUEST_URI} !^/admin.php$
RewriteRule ^(.+?)\.php$ /$1.html [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+?)\.html$ /$1.php [L]