I'm pasting my full htaccess file, for clarity, as to be honest, I'm not entirely sure if I have to include my non-default directives inside the <IfModule mod_rewrite.c>
bits or separately (below - I've seen it somewhere).
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
#redirect index to homepage
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
#prevent hotlinking
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?www.example.com [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ - [NC,F,L]
#redirect galleries to portfolio
RewriteRule ^galleries/(.*)$ /portfolio/$1 [R=301,NC,L]
#prevent access to wp-config
<files wp-config.php>
order allow,deny
deny from all
</files>
</IfModule>
The relevant bit is this one:
#redirect galleries to portfolio
RewriteRule ^galleries/(.*)$ /portfolio/$1 [R=301,NC,L]
Now, if I go to http://subdomain.example.com/galleries/headshots/
I'm expecting it to redirect to http://subdomain.example.com/portfolio/headshots/
, but instead nothing at all happens.
I even tried the following (adding slashes at the end of both, the source and target):
#redirect galleries to portfolio
RewriteRule ^galleries/(.*)$/ /portfolio/$1/ [R=301,NC,L]
Also note that I'm using a subdomain, but I wouldn't expect that to be an issue.
Does the L
bit in the directives above count? I understand those are to tell the script to stop execution of anything after.