.htaccess for 301 Redirect
-
Hi,
I’m migrating my website from Shopify to WP. Shopify uses mysite.com/news/article1 and I want to change to mysite.com/blog/article1. The domain name doesn’t change.
I’d like to know if I’m doing the right thing or not.
I’d like to add 301 Redirect:
Redirect 301 /news/page1 /blog/page1 Redirect 301 /news/page2 /blog/page2 Redirect 301 /news/page3 /blog/page3 ... ...
Q1. I added them under
<IfModule mod_rewrite.c>
. Is it correct?Q2. I’d like to change from /news/ to /blog/, is there a better way to do it rather than adding all the posts one by one.
# BEGIN WordPress # The directives (lines) between "BEGIN WordPress" and "END WordPress" are # dynamically generated, and should only be modified via WordPress filters. # Any changes to the directives between these markers will be overwritten. <IfModule mod_expires.c> ExpiresActive On ExpiresByType image/jpg "access plus 24 hours" ExpiresByType image/jpeg "access plus 24 hours" ExpiresByType image/gif "access plus 24 hours" ExpiresByType image/png "access plus 24 hours" ExpiresByType text/css "access plus 24 hours" ExpiresByType application/pdf "access plus 1 week" ExpiresByType text/javascript "access plus 24 hours" ExpiresByType text/html "access plus 5 minutes" ExpiresByType image/x-icon "access plus 1 year" ExpiresDefault "access plus 24 hours" </IfModule> <ifModule mod_headers.c> Header set X-Endurance-Cache-Level "2" </ifModule> <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] Redirect 301 /news/page1 /blog/page1 Redirect 301 /news/page2 /blog/page2 Redirect 301 /news/page3 /blog/page3 # more redirect ... ... </IfModule> # END WordPress # php -- BEGIN cPanel-generated handler, do not edit # Set the “ea-php74” package as the default “PHP” programming language. <IfModule mime_module> AddHandler application/x-httpd-ea-php74 .php .php7 .phtml </IfModule> # php -- END cPanel-generated handler, do not edit
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘.htaccess for 301 Redirect’ is closed to new replies.