Fern Libre
asked on
Best SEO practice for httaccess redirection rule
Hello,
I want to redirect OLD author pages to new Author pages in my Wordpress site.
OLD URL: https://site.com/author/ebooks/
NEW URL: https://site.com/ebook-author/
I need help with the httaccess rule for this redirection using best SEO practice.
Thank you for your help!
I want to redirect OLD author pages to new Author pages in my Wordpress site.
OLD URL: https://site.com/author/ebooks/
NEW URL: https://site.com/ebook-author/
I need help with the httaccess rule for this redirection using best SEO practice.
Thank you for your help!
A more pressing concern will be if you'll ever have to change your link target.
If your target might ever change, use a 302.
If you're unsure, use a 302.
301s are cached forever at the browser level, so if you do a 301 + change the target link, then old visitors will always see old target + new visitors see new target. This can become very confusing + impossible to determine what's going on with conversions.
If your target might ever change, use a 302.
If you're unsure, use a 302.
301s are cached forever at the browser level, so if you do a 301 + change the target link, then old visitors will always see old target + new visitors see new target. This can become very confusing + impossible to determine what's going on with conversions.
ASKER
Thank you for your solution.
Unfortunately it is not working. I placed the rule in the .htacces for testing and old URL is not redirecting to new:
What could be wrong?
Unfortunately it is not working. I placed the rule in the .htacces for testing and old URL is not redirecting to new:
# 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]
RewriteRule ^author/ebooks/(.*)$ https://free-ebooks.com/ebook-author/$1 [R=301,NC,L]
</IfModule>
# END WordPress
What could be wrong?
Turn on rewrite debugging at level 4, restart Apache, and have a look at the rewrite log to see where it is going wrong.
# RewriteLog: Location of the mod_rewrite log file
RewriteLog /where/ever/rewrite_mysite
# RewriteLogLevel: Controls verbosity of mod_rewrite log
# 0=off, 9=max
RewriteLogLevel 4
ASKER
I have just changed the position and it worked perfect.
Thank you so much!
RewriteEngine On
RewriteBase /
RewriteRule ^author/ebooks/(.*)$ https://free-ebooks.com/ebook-author/$1 [R=301,NC,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
Thank you so much!
This question needs an answer!
Become an EE member today
7 DAY FREE TRIALMembers can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
This code should be placed in the httpd.conf for the host or the vhost configuration file so that it is obvious to whoever next maintains the site. Using htaccess may be convenient but it is, IMO, poor practice as far as supportability when it comes to "Why is the site improperly doing this?" and a new maintainer then has to go chase through the contents of all the htaccess files.
This redirect will redirect the URL but not any options fields. If there are options fields those must be addressed with a more complex rule.
Open in new window