When a URL contains a + or % character, I want to redirect that URL to a php redirection script I have written. Regex (.+)(?:+|%)(.*)? works and finds any URLs that contains + or % but it wont work when used in htaccess like –
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} (.+)(?:\+|%)(.+)?
RewriteRule ^(.*)$ /directory/content/my-redirect-rewrite.php [L]
What am I doing wrong? Thanks for taking a look.
Since you aren’t using the RewriteCond capture groups theres no need for ?: and dont really need the (.+) groups either. Try this, and remove the
R=302if you don’t want it to actually change the url displayed in the browser