Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.htaccess rewrite rule explained (simple)

Tags:

.htaccess

  RewriteCond %{SERVER_PORT} !^443$
  RewriteRule MATCHME https://%{SERVER_NAME}%{REQUEST_URI} [L,R]

IF MATCHME is not in the URL then will the RewriteRule NOT Be processed? Could you link me to some documentation?

like image 542
Chris Muench Avatar asked Feb 07 '26 19:02

Chris Muench


1 Answers

That is correct. If the pattern MATCHME is not present, no rewriting will take place.

If you require a catch-all rule to be matched when your RewriteCond is active, you can specify an additional rule like:

RewriteCond %{SERVER_PORT} !^443$
RewriteRule MATCHME https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
# Catch-all rule
RewriteRule ^(.*)$ https://%{SERVER_NAME}/someotherpage [L,R,QSA]

Review the mod_rewrite documentation.

like image 116
Michael Berkowski Avatar answered Feb 09 '26 11:02

Michael Berkowski



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!