Z
Z
zooks2015-10-12 08:25:47
Apache HTTP Server
zooks, 2015-10-12 08:25:47

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/-nameto 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

1 answer(s)
N
Nadz Goldman, 2015-10-13
@zooks

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 question

Ask a Question

731 491 924 answers to any question