Delete page and redirect to new page

Hi

I’m using Backlight 4. I have an old page that I want to delete and redirect attempts to open it (grom a Google search etc) to a new page.

Is that possible?

Many thanks

Andy

Yes, it is with some .htaccess magic. Here is a good article showing you how to go about this: https://wpscholar.com/blog/simple-redirects-with-htaccess/

Thanks Daniel, but that’s not working for me…

I’ve added this line to my .htaccess:

Redirect 301 “/Lake_District_Calendar_2020” “/Lake_District_2022_Calendar”

But when I access the old page the browser shows this as the URL and displays the old page’s content:

https://andybellphotography.com/Lake_District_2022_Calendar/?mod_rewrite=on&page=Lake_District_Calendar_2020/

My current workaround is to replace the old page’s content with the new, but it’s not a nice fix…

Andy

Add

This works…

RewriteEngine on
RewriteRule ^Lake_District_Calendar_2020/?$ $1/Lake_District_2022_Calendar$2 [L,R=301]

:slight_smile:

I just encountered the same problem. Another one of my pages redirects fine. Did anybody find a proper solution?

The redirect works for a gallery page but not one of my regular pages.

Thanks

Actually, none of my single 301 redirects work now and the resulting URLs have something similar to this appended to the end. ?mod_rewrite=on&page=TBOI/index.html If remove the extra stuff it works.

Could this have something to do with the site redirects for https?

Any ideas would be appreciated. Thanks again.

Is Backlight doing some PHP business that would cause this?

I don’t think so. Since Backlight now supports native https redirect, I would remove the respective lines from your .htaccess file and enable the redirect in Backlight admin > settings.

That comes from the .htaccess file.

What’s your rewrite rule? Do you have you rewrite rules before or after Backlight’s rules? Do you have a link to your page?

My rule is “Redirect 301 /gallery/TBOI/ /ireland/”

I’ve tried at the beginning before anything else and at the end, after everything with the same result.

This the old link: http://www.bretculp.com/gallery/TBOI/index.html

With the redirect, the resulting URL is “https://www.bretculp.com/ireland/?mod_rewrite=on&page=TBOI/index.html”. If you remove everything from the “?” it works as it should,

There is an .htaccess.ssl file in my home directory that I didn’t create. It starts with the following code.

.# ------------------------------------------------------------------------------
.# | Web fonts access |
.# ------------------------------------------------------------------------------

Thanks for your help.

This is my .htaccess file without my redirects. Some of the line have disappeared here as as a result of the formatting.

.
. <FilesMatch “.(eot|font.css|otf|ttc|ttf|woff)$”>
. Header set Access-Control-Allow-Origin ""
.
.
.
.
. RewriteEngine On
.
…# The below two lines will take a REQUEST_URI like /directory./foobar.php and set the variable BASE to /directory/
. #RewriteCond %{REQUEST_URI}::$1 ^(.
?/)(.)::\2$
. #RewriteRule ^(.
)$ - [E=BASE:%1]
.
. RewriteBase /
. RewriteCond $0#%{REQUEST_URI} ([^#])#(.)\1$
. RewriteRule ^.$ - [E=BASE:%2]
.
. RewriteRule ^(.
)$ - [E=QS:mod_rewrite=on]
.
. RewriteCond %{REQUEST_FILENAME} !-f
. RewriteRule ^([^/.])-single.php$ %{ENV:BASE}single.php?%{ENV:QS}&id=$1 [QSA,L]
.
. # Attempt to load dynamic resources if file doesn’t exist
. RewriteCond %{REQUEST_FILENAME} !-f
. RewriteRule ^([^/.]
).(css|js|gif|png|jpg)$ %{ENV:BASE}index.php?%{ENV:QS}&extension=$2&name=$1 [QSA,L]
.
. #RewriteCond %{QUERY_STRING} !mod_rewrite=on
. #RewriteRule ^index.php$ %{ENV:BASE}index.php?%{ENV:QS} [QSA,L]
.
. RewriteCond %{QUERY_STRING} !mod_rewrite=on
. RewriteRule ^mobile.php$ %{ENV:BASE}mobile.php?%{ENV:QS} [QSA,L]
.
. RewriteCond %{QUERY_STRING} !mod_rewrite=on
. RewriteRule ^(.)download.php %{ENV:BASE}download.php?%{ENV:QS} [QSA,L]
.
. # Address is /
. RewriteRule ^$ %{ENV:BASE}index.php?%{ENV:QS} [QSA,L]
.
. RewriteCond %{REQUEST_FILENAME} !-f
. RewriteCond %{REQUEST_FILENAME} !-d
. RewriteRule ^(.
)$ %{ENV:BASE}index.php?%{ENV:QS}&page=$1 [QSA,L]
.
.
.

if you surround the code with three backticks (```) then the missing code should show up.
See this for more:

I would try with following and have it before the Backlight code:

RewriteCond %{QUERY_STRING} ^$
RewriteRule ^gallery/TBOI/$ /ireland/? [R=301,L]

Thanks, Daniel. Unfortunately, that does work for me either. I get the same result.

Do you know what should be in the .htaccess in the /gallery directory?

Did you try to redirect it directly to the target https://www.bretculp.com/gallery/ireland-photo-gallery/?

Thanks for your help, Daniel, but it’s still not working.