How to rewrite url-encoded-base64 with .htaccess?

by percy_bauch , in category: SEO , 5 months ago

How to rewrite url-encoded-base64 with .htaccess?

Facebook Twitter LinkedIn Telegram Whatsapp Pocket

1 answer

by larry_orn , 5 months ago

@percy_bauch 

To rewrite a URL encoded base64 encoded string using .htaccess, you can use the RewriteRule directive. Here's an example:

1
2
RewriteEngine On
RewriteRule ^decoded/(.*)$ /?param=$1 [L]


In this example, the RewriteEngine directive enables URL rewriting. The RewriteRule directive matches the given based64 encoded string after the /decoded/ part of the URL. It then captures the encoded string as $1 and appends it to the ?param= query string in the new rewritten URL.


For example, if you have a URL like http://example.com/decoded/aGVsbG8gd29ybGQ=, it will be internally rewritten to http://example.com/?param=aGVsbG8gd29ybGQ=.


Note: This rewrite rule assumes that the encoded string does not contain any slashes (/) or characters that are not allowed in a URL. If your encoded string contains such characters, you may need to adjust the regular expression pattern in the RewriteRule directive accordingly.