How to put % or any other in rewriterule in .htaccess?

by jaycee_rowe , in category: SEO , a year ago

How to put % or any other in rewriterule in .htaccess?

Facebook Twitter LinkedIn Telegram Whatsapp Pocket

1 answer

by jose_gulgowski , a year ago

@jaycee_rowe 

To include the percent (%) symbol or any other special character in a RewriteRule in .htaccess, you need to use the URL-encoded version of the character.


For example, to include the percent (%), you need to replace it with %25. Similarly, for any other special characters, you can use their corresponding URL-encoded representation.


Here's an example of how to include a "%" symbol in a RewriteRule:

1
RewriteRule ^example/%25category$ example.php?category=example_category [L]


In the above example, the URL pattern "^example/%25category$" will match "example/%category" in the URL. The "%25" represents the "%" character when it is URL-encoded.


Make sure to save and test your .htaccess file after making any changes.