简体   繁体   中英

301 permalink redirect htaccess

I've searched to no avail, hoping that someone can be my hero. I have 2 things going on.

I recently moved wordpress to the root folder and currently have the following redirect in my htaccess and all is working properly.

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.website.com
RewriteRule ^blog/(.*)$ http://www.website.com/$1 [L,R=301]

#BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

However, I have also changed my blog permalinks from /archives/post-id to /YY/MM/post-name. How can I implement the permalink redirect so I don't have to redirect each individual blog post? I have tried numerous different things with no luck. Also, where in particular should I paste the code in my file (above? below?) so as to not interfere and still work with the initial subdirectory to root redirect? Thank you.

In case someone ever wants to do something similar, I was able to make a slight modification and found something that worked for me.

I decided to change the permalinks from archives/post-id to archives/post-id/post-name.

To accomplish this I added the following code to my htaccess file above my #BEGIN Wordpress area...

# Redirect permalink archive/post-id to archive/post-id/post-name structure.
RedirectMatch 301 ^/archives/(\d+)$ http://www.website.com/archives/?p=$1

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