简体   繁体   中英

Regex for .htaccess to change urls

I have urls from a joomla install that are coming in like:

http://blah.com/blog/543-this-is-the-blog-title

I need to change them for wordpress to:

http://blah.com/this-is-the-blog-title

I know it can be easily done using regex in the .htaccess file.

Yes it can be done easily.

Put this code in your DOCUMENT_ROOT/.htaccess file:

RewriteEngine On

RewriteRule ^blog/[0-9]+-(.+)$ /$1 [L,NC,R=301]

Make sure this is the first rule in your DOCUMENT_ROOT/.htaccess file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM