admin管理员组

文章数量:1323353

I just migrated one of my old websites to wordpress but running into issues with the 301's of the old url's

old url /11/companyname

new url /office/companyname/

This is the code i came up with

RewriteEngine On
RewriteRule ^([a-zA-Z-]+)/(.*)?$ /office/$2/ [R=301,L]

It redirects fine when i add the trailing slash i.e. /11/companyname/ but not without.

I just migrated one of my old websites to wordpress but running into issues with the 301's of the old url's

old url /11/companyname

new url /office/companyname/

This is the code i came up with

RewriteEngine On
RewriteRule ^([a-zA-Z-]+)/(.*)?$ /office/$2/ [R=301,L]

It redirects fine when i add the trailing slash i.e. /11/companyname/ but not without.

Share Improve this question asked Feb 28, 2017 at 16:47 thomaswtranthomaswtran 152 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Try below Rule,

RewriteRule ^([a-zA-Z-]+)/(.*)/?$ /office/$2/ [R=301,L]

It makes trailing slash optional.

本文标签: htaccess301 Redirect Old URL to New Wordpress Page