Posts by Vipin Kumar

    I have a situation where I want to redirect all the incoming URL with %20 in the URL to be replaced with - for all occurrences.

    Now I get this link -

    301 Redirect to replace all spaces to hyphens on this page

    which gives this solution

    1. Options +FollowSymlinks -MultiViews
    2. RewriteEngine on
    3. RewriteCond %{THE_REQUEST} (\s|%20)
    4. RewriteRule ^([^\s%20]+)(?:\s|%20)+([^\s%20]+)((?:\s|%20)+.*)$ $1-$2$3 [N,DPI]
    5. RewriteRule ^([^\s%20]+)(?:\s|%20)+(.*)$ /$1-$2 [L,R=301,DPI]

    which works perfect but there is one small issue with this solution. This also redirects the request for images/docs/pdf or other resources and results in 404

    Can i have something which will redirect only certain sections and not all incoming links like it will replace and redirect only for

    1. to
    3. or
    4. to

    and leave all other requests intact??