# 301 Redirects in .htaccess: Copy-Paste Examples

DevFeed: [301 Redirects in .htaccess: Copy-Paste Examples](<https://devfeed.tech/articles/301-redirects-in-htaccess-copy-paste-examples-102000.md>)

Original publisher: [Read original article](<https://markodenic.com/htaccess-301-redirect/>)

Author: Marko

Published: 2026-10-27T09:00:00Z

Content type: tutorial

Language: en

Sources: [Marko Denic Blog](<https://devfeed.tech/sources/marko-denic-blog.md>)

Topics: [Mod\_rewrite](<https://devfeed.tech/topics/mod-rewrite.md>), [WordPress](<https://devfeed.tech/topics/wordpress.md>), [Search engine optimization (SEO)](<https://devfeed.tech/topics/seo.md>), [nginx](<https://devfeed.tech/topics/nginx.md>)

Tags: [apache](<https://devfeed.tech/tags/apache.md>), [browsers](<https://devfeed.tech/tags/browsers.md>), [cache](<https://devfeed.tech/tags/cache.md>), [curl](<https://devfeed.tech/tags/curl.md>), [domain](<https://devfeed.tech/tags/domain.md>), [ftp](<https://devfeed.tech/tags/ftp.md>), [google](<https://devfeed.tech/tags/google.md>), [htaccess](<https://devfeed.tech/tags/htaccess.md>), [http](<https://devfeed.tech/tags/http.md>), [http-2](<https://devfeed.tech/tags/http-2.md>), [https](<https://devfeed.tech/tags/https.md>), [redirect](<https://devfeed.tech/tags/redirect.md>), [regex](<https://devfeed.tech/tags/regex.md>), [seo](<https://devfeed.tech/tags/seo.md>), [testing](<https://devfeed.tech/tags/testing.md>), [web-development](<https://devfeed.tech/tags/web-development.md>), [wordpress](<https://devfeed.tech/tags/wordpress.md>)

## AI overview

The excerpt provides Apache `.htaccess` 301 patterns for individual paths, folders, domain changes, HTTP-to-HTTPS, host-name variants, trailing slashes, and query strings. It distinguishes simple `Redirect` rules from regex-based `RedirectMatch` and conditional `mod_rewrite`, noting that `Redirect` matches path prefixes and that specific rules should precede broader ones. For WordPress, custom rules belong above its managed rewrite block; a plugin is an alternative. It recommends checking responses with `curl -I` because browsers cache permanent redirects, and avoiding chains, loops, accidental 302s, and redirects to unrelated pages. The excerpt also notes that nginx uses server configuration rather than `.htaccess`, with `$is_args$args` needed to preserve query strings.

## Source excerpt

Every 301 redirect you'll need in .htaccess: single pages, folders, whole domains, HTTP to HTTPS, www to non-www, trailing slashes and regex patterns, plus testing them and doing it right in WordPress.