开发者

Wordpress rebuild - 301 redirect old pages (*.php) to pretty permalinks

开发者 https://www.devze.com 2023-02-22 13:40 出处:网络
Here is what I need to do: old pages are mydomain.com/something.php new pages are rebuilt in Wordpress identified using pretty permalinks so they are mydomain.com/something/

Here is what I need to do:

old pages are mydomain.com/something.php

new pages are rebuilt in Wordpress identified using pretty permalinks so they are mydomain.com/something/

I need to figure out what the rewrite rule sho开发者_C百科uld look like. I have crawled the web and can't find anything exactly like it.


Something like:

RewriteEngine On
RewriteRule   ^(.*)\.php$ $1/ [R=permanent]

The (.*) is a "group" of characters before the .php, and $1 refers to that group of characters. So just add a slash to the group and send the browser to the new URL with an HTTP code 301 (permanent redirect)


Try this:

RewriteEngine On
RewriteBase /

#Ignore index.php 
RewriteCond %{REQUEST_URI} !index\.php
RewriteCond %{REQUEST_URI} !(wp-login|wp-admin|wp-includes)
RewriteCond %{REQUEST_URI} ^(.*)\.php$
RewriteRule ^(.*)\.php$ $1/ [R=301,L]

#"Standard" Wordpress Rewrite Stuff
RewriteRule ^index\.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !/catalog
RewriteRule . /index.php [L] 
0

精彩评论

暂无评论...
验证码 换一张
取 消