I want to convert single (first) dash into slash. I have two urls here:
Actuall url:
http://localhost/wordpress/accessories-car-alarm-system
.
Should redirect to
http://localhost/wordpress/accessories/car-alarm-system
.
I want to convert this specific url from first one to second one. I am using this code but it doesn’t work properly.
Whole htaccess file:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress/
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
RewriteRule ^/?accessories/(.+)$ /accessories-$1 [L,NC]
</IfModule>
# END WordPress
Tried this too:
RewriteRule ^/?accessories/(.+)$ /accessories-$1 [L,NC]
Still not working
Use:
Without the
/
at the beginning in .htaccessYou can not use regex in rewrite RewriteTarget ,try
Reference : https://httpd.apache.org/docs/current/mod/mod_rewrite.html
Shouldn’t it be