Reputation: 1105
I want to redirect a url which has 4-5 characters after last slash and also has a +
at the end of it.
(Note: the +
symbol doesn't count in length)
I was able to make it work for 4-5 characters condition:
RewriteCond %{THE_REQUEST} ^(GET|HEAD)\ /(index\.php)?\?id=([0-9a-zA-Z]{4,5}+)([^\ ]*)
RewriteRule ^ /%3?%4 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([0-9a-zA-Z]{4,5}+)/?$ someFile.php?id=$1 [L,QSA]
I'm not able to make it work for the +
symbol though i tried the condition ([0-9a-zA-Z\+]{4,5}+)
but doesn't work..also I think the condition ([0-9a-zA-Z\+]{4,5}+)
will still work if there is no +
symbol at the end..
Example:
From:
http://example.com/1234+
To:
http://example.com/someFile.php?id=1234
NOTE: Redirect only if there is a +
at the end.
Upvotes: 1
Views: 343
Reputation: 785481
You need to escape the +
since it is a special regex symbol.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([0-9a-zA-Z]{4,5})\+?/?$ someFile.php?id=$1 [L,QSA]
Upvotes: 1