How to redirect urls with blank space in .htaccess?

by haylee.mertz , in category: Third Party Scripts , 3 months ago

How to redirect urls with blank space in .htaccess?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by aniya.jaskolski , 3 months ago

@haylee.mertz 

To redirect URLs with blank spaces in .htaccess, you can use the following steps:

  1. Open your .htaccess file in a text editor.
  2. Add the following line of code to redirect URLs with blank spaces: RewriteRule ^(.*)s(.*)$ /$1-$2 [L,R=301]
  3. Save the .htaccess file and upload it to your server.


This code will redirect URLs with blank spaces to URLs with hyphens. For example, a URL like "example.com/my page" will be redirected to "example.com/my-page".


Make sure to test the redirect to ensure it is working as expected.