If you have access to the VirtualHost
config for the site, I think mod_rewrite
would to be up to the task (when placed in said <VirtualHost>
directive block):
<IfModule mod_rewrite.c>
RewriteMap lc int:tolower
RewriteEngine On
RewriteBase /
RewriteRule [A-Z] ${lc:$0} [R=301]
RewriteRule ^(.*)/shopping-categories/(.*)$ $1/category/$2 [R=301]
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R=301]
</IfModule>
You may need to restart the Apache service to re-parse the VirtualHost
configuration.
The RewriteMap
directive maps a "to lowercase" behavior that's packaged with mod_rewrite
, and is the only directive which absolutely must be in the <VirtualHost>
directive block. All other directives could be placed in a .htaccess
file or <Directory>
directive block.
RewriteRule [A-Z] ${lc:$0} [R=301]
: If the requested URI-path contains an uppercase letter, apply the "to lowercase" map against the entire path and set up a permanent redirect.
RewriteRule ^(.*)/shopping-categories/(.*)$ $1/category/$2 [R=301]
: If the (now most definitely lowercase) URI-path contains "/shopping-categories/", replace it with "/category/" and set up a permanent redirect.
RewriteCond %{HTTPS} !=on
: If the request was not made using HTTPS...
RewriteRule ^(.*) https://%{SERVER_NAME}/$1 [R=301]
: ...rewrite it using the HTTPS schema and set up a permanent redirect.
As no L
or END
flags are specified, Apache will test all rewrite rules and redirect only once if any rule was applied.
ADDENDUM
The above directives should function equally as well in a server-level configuration (often httpd.conf
). However, a VirtualHost
block is preferable as it limits the changes to specifically to applicable requests (and thus resource overhead, behavior alterations, etc.). If your dedicated server does not appear to load a <VirtualHost>
directive block for your website at any point you can easily implement one, even if you only plan on hosting one website on the server - this is a fairly standard practice and will not introduce any great complexity nor resource overhead to the webserver. Review the Apache documentation on Configuration Files and the VirtualHost examples for more information.
<VirtualHost>
block. If it does not, all it takes to add one is two to four additional lines in a configuration file - that's all there is to it. That in mind, entirely switching webservers would be the more difficult and time-consuming solution.