Apache Rewrite

From Michael's Information Zone
Jump to navigation Jump to search

No Encoding

[1]While working with nextcloud, I ran into a rewrite rule that would not keep slashes as I needed them. This was caused by the slashed being converted in a browser, then someone copying the converted URL as a link in another site.

[2] I was scratching my head as to why %2 was being turned into %252 after a migration from one vhost to another. Found out I needed to add [NE] to the rewrite rule in order for the slashed to be registered correctly.

<VirtualHost *:80>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^/(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [NE]
</VirtualHost>