Difference between revisions of "Apache Rewrite"

From Michael's Information Zone
Jump to navigation Jump to search
 
Line 5: Line 5:
 
<ref>http://tkurek.blogspot.com/2013/06/252f-instead-of-2f-in-url-apache.html</ref> I was scratching my head as to why %2 was being turned into %252 after a migration from one vhost to  
 
<ref>http://tkurek.blogspot.com/2013/06/252f-instead-of-2f-in-url-apache.html</ref> 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.
 
another. Found out I needed to add [NE] to the rewrite rule in order for the slashed to be registered correctly.
 +
<br>
 +
<pre>
 +
<VirtualHost *:80>
 +
RewriteEngine On
 +
RewriteCond %{HTTPS} off
 +
RewriteRule ^/(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [NE]
 +
</VirtualHost>
 +
</pre>

Latest revision as of 12:55, 15 April 2019

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>