I have lots of user profile url and want remove user id from the url and redirect 301 with .htaccess For example my current url is http://www.example.com/1084-jerome-smith/profile.php and want redirect this way http://www.example.com/jerome-smith/profile.php
You may try this:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/(.*)/[\d]+-(.*)$ [NC]
RewriteRule .* %1/%2 [R=301,L]
It will redirect permanently:
http://www.example.com/1084-jerome-smith/profile.php
To:
http://www.example.com/jerome-smith/profile.php
Will redirect any URL with this format: http://www.example.com/OptionalFolders/NumericID-anything-anything/anyname.php
, where NumericID
is the number 1084
to be removed in this case.