WordPress.org

Forums

Redirection
Proper way to input URLs containing spaces? (10 posts)

  1. meggan
    Member
    Posted 2 years ago #

    I have a bunch of redirects in place for some old URLs that contain spaces, and the Redirection plugin does not seem to be handling them how I'd expect.

    For instance, let's say my old URL is /Ultraspecial Systems.html

    and I want it to redirect to:
    /ultraspecial-systems/

    When I input the "source" URL, I tried it using the %20 in place of the space, like so:
    /Ultraspecial%20Systems.html
    ...but this does not seem to get picked up when someone hits that old URL. The user sees the 404 error (and it gets logged in Redirection as a 404) instead of redirecting to the new page I've created.

    If I leave out the %20 in the source URL like so:
    /Ultraspecial Systems.html
    ...it displays the URL just like that in the Source URL input field, but strips out the space in the link in the Source URL label element, so the link it's targeting is actually
    /UltraspecialSystems.html
    ...which is incorrect.

    What's the proper way to input a URL with spaces so it redirects successfully?

    http://wordpress.org/extend/plugins/redirection/

  2. morestar
    Member
    Posted 2 years ago #

    I've seen the same problem while using the redirection plugin. If there are spaces in the URL's it just doesn't work at all - spaces and quotes - quotes as " or in ascii form.

    Any help or update on this is more than appreciated.

  3. JochenT
    Member
    Posted 2 years ago #

    Check the Regex option and enter the URL as a regular expression as follows:
    /Ultraspecial\s+Systems\.html
    If you want this case insensitive you may add (?i) in front of the URL:
    (?i)/Ultraspecial\s+Systems\.html

  4. meggan
    Member
    Posted 2 years ago #

    JochenT, thank you so much for your help! This solution totally worked for me.

  5. meggan
    Member
    Posted 2 years ago #

    Also wanted to mention - if you implement the above solution, the "Source URL" clickable label link will still be handled incorrectly, like so:

    /Ultraspecials+Systems.html

    ...but that's fine - if you visit the actual URL (/Ultraspecial%20Systems.html) it will successfully redirect you to the new page. You just can't click on it from the Redirection rule, which is a perfectly fine trade-off to me since the redirects are working!

  6. srmrktg
    Member
    Posted 2 years ago #

    Hi I have tried various methods (including those mentioned above) of getting the following "source URL" with a space in it to redirect with the Redirect plugin but it doesn't want to work for some reason.
    /Starlink-Website/SheerHost website/coax.htm

    I have just added / as the target URL to redirect to the home page, which works for other URLs just not this one with a space in.

    Any assistance on achieving this would be appreciated.

  7. alisaleem252
    Member
    Posted 2 years ago #

    I have moved from Blogger to wordpress
    i have successfully redirected all labels to category
    http://site.com/category/Bikes
    but the problem comes when category has two words and has space in it
    http://site.com/category/Bikes%20wallpapers/
    it says 404 Page not found
    so when i manually replace "%20" to "-"
    page show up....
    is it a way to to this for all link? i have more than 500 such links :s

    Conclusion:
    Want to make it so both show same category page.
    http://site.com/category/Bikes%20wallpapers/
    http://site.com/category/Bikes-wallpapers/

  8. Jesús Franco
    Member
    Posted 2 years ago #

    Use this rewrite rule for changing spaces to dashed before passing that to WP

    After Rewrite Engine on:

    RewriteRule (.*)\ (.*) $1-$2

    It will cycle through all the spaces contained in the URL used by the visitors, until there is no more spaces.

  9. alisaleem252
    Member
    Posted 2 years ago #

    Thank you Franco for your reply
    i added the following line but still 404

    this is my .htaccess

    #Redirect archives
    RewriteRule ^([0-9]{4})_([0-9]{1,2})_([0-9]{1,2})_archive.html$ $1/$2/ [L,R=301]
    #Redirect labels/categories
    RewriteRule ^search/label/(.*)$ category/$1/ [L,R=301]
    RedirectMatch 301 ^/([0-9]{4})/([0-9]{2})/([^/]+).html$ http://www.MYSITE.com/$3
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule (.*)\ (.*) $1-$2
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress
  10. Jesús Franco
    Member
    Posted 2 years ago #

    try placing the custom rewrites after rewritebase / and escaping dots like this: \.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Redirection
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic