What’s the htaccess code for redirects?
-
hi,
I’ve seen different articles about redirecting pages and posts, but can’t get them to work. Does anyone know the code that works?
I want the specific htaccess code for pages and posts.
For example: This post https://greenesrelease.com/?p=4806
to redirect to https://greenesrelease.com/grief/?page_id=201Is there a different code for posts and pages?
Here are some online instructions that I found.
This is one I can’t make sense of:
https://www.example.com/page.php?id=13Where a query string is used, you’ll need to use a rewrite solution. Using the page.php?id=13 example, here’s what you’ll need to use in your htaccess file:
RewriteEngine on
RewriteCond %{QUERY_STRING} ^id=13$
RewriteRule ^/page.php$ https://www.example.com/newname.htm? [L,R=301]In the example above the id=13 should be replaced with the query string of the page you wish to redirect and the page.php with the name of your file prior to the query string.
This is another:
RewriteCond %{QUERY_STRING} id=1
RewriteRule category \.aspx https://www.domain.com/keyword-category-1.php [R=301,L]Thanks for your help in advance
- The topic ‘What’s the htaccess code for redirects?’ is closed to new replies.