Answer the question
In order to leave comments, you need to log in
How to redirect from domain.com/-name to domain.com/name in htaccess?
Hello friends.
Tell me how to make a 301 redirect from example.com/-name
to example.com/name
, where "name" is an arbitrary page name containing Latin letters, hyphens and numbers. Those. if there is a hyphen (-) after the domain name and a slash, then such a path redirects to a path without a hyphen.
Current .htaccess rules:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
Answer the question
In order to leave comments, you need to log in
Something like this:
RewriteRule ^(.*)-(.*)$ /$1 [L,R=301]
Or,
rewriterule ^-name(.*)$ domain.com/name$1 [ r=301,nc]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question