Replace part of the URL with .htaccess

I had to change the name of the subpage, and now the problem is that all the common links on Facebook, Twitter, etc. no longer work.

This is why I am trying to redirect only part of the URL to .htaccess, but I have no solution yet.

It should work as follows:

www.mydomain.com/feeds/details/ --> www.mydomain.com/highlights/details/

I hope you help me!

+4
source share
2 answers

It will depend on your server, but you are looking for something in this direction.

    //Rewrite to www
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com[nc]
RewriteRule ^(.*)$ http://www.example.com/$1 [r=301,nc]

//301 Redirect Entire Directory
RedirectMatch 301 /feeds(.*) /highlights/$1
+4
source

You can try rewriting the url with RewriteRule, for example, as follows:

.htaccess

RewriteEngine on
RewriteRule ^/feeds/details$ /highlights/details/

Hope this works for you.

You can find more information here .

+1

Source: https://habr.com/ru/post/1663643/


All Articles