Rahul Chaturvedi Rahul Chaturvedi -4 years ago 55
PHP Question

How to write htaccess - mod_rewrite rules for retrieving querystring values in multiple languages?


^([a-zA-Z0-9%_-]+)([\.|\/|@|%])([a-zA-Z0-9%_-]+)/$ index.php?t=$1&v=$2&q=$3 [QSA]

This is an attempt to capture query string values. How should I replace


such that all
or for that matter
values are considered valid inputs?

Environment is
Apache2 - PHP 5.6+

Incoming queries:

  1. example.com/query/información@importante

  2. example.com/query/महत्वपूर्ण@जानकारी

  3. example.com/query/முக்கியமான@தகவல்

  4. example.com/query/důležitá@informace

Expected variables:

  • t=información

  • v=@

  • q=importante

Answer Source

Try this rule in query/.htaccess:

RewriteRule ^([^/@]+)(@)([^/]+)/?$ index.php?t=$1&v=$2&q=$3 [QSA,L]
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download