Apache Mod Rewrite - Replace: a character with another

I am trying to rewrite the entire URL containing the ':' character in it to another character. http://en.wikipedia.org/wiki/Filename#Reserved_characters_and_words

Example:

http://example.com/some_interesting:info http://example.com/some_interesting_info http://example.com/some:interesting:info http://example.com/some:interesting_info 

everyone will point to this file

 some_interesting_info 

How can i do this?

EDIT: more tests

it works

 RewriteRule ^(.*)_(.*) $1$2 [L] RewriteRule ^(.*)\_+(.*) $1$2 [L] 

test_rewrite.html is sent to testrewrite.html

is not

 RewriteRule ^(.*):(.*) $1$2 [L] RewriteRule ^(.*)\:+(.*) $1$2 [L] 

test: rewrite.html gives 403

In terms of eliminating the character in the middle. Tested with xammp 1.7.1

+3
source share
2 answers

Try the following rules:

 RewriteRule ^/([^:]*):([^:]*:.*) /$1_$2 [N] RewriteRule ^/([^:]*):([^:]*)$ /$1_$2 
+3
source

Here is a link to the RewriteRule .

 RewriteRule ^/some[_:]interesting[_:]info$ /some_interesting_info [L] 
0
source

Source: https://habr.com/ru/post/899821/


All Articles