Changing a page URL is easy. Making sure visitors and search engines reach the new address is the part that needs attention.
Use our Htaccess Redirect Generator to write redirect rules without writing them by hand. Type in the old path name, the new path name, create the rule, and copy it into your .htaccess file.
Useful when moving a page, changing a permalink, switching domains, enabling HTTPS, or when you wish your website to always use the www domain or non-www domain.
What Is an Htaccess Redirect?
An .htaccess file is a configuration file that is typically found on websites that are served by the Apache web server. It can, among other things, specify to the Apache server what to do when a user accesses a specific URL.
For example, suppose you previously had:
example.com/old-services
but the page now lives at:
example.com/services
Instead of leaving visitors at a missing page, you can create an htaccess redirect from the old URL to the new URL.
Anyone visiting the old address is then automatically sent to its replacement.
How to Use the Htaccess Redirect Generator
You don’t need to memorize Apache redirect syntax to create a basic rule.
Simply:
- Select the redirect you need.
- Enter the old URL or path.
- Add the destination URL.
- Generate the
.htaccessrule. - Check the generated code.
- Copy it into your website’s
.htaccessfile. - Visit the old URL to confirm the redirect works.
Before changing an existing .htaccess file, save a backup copy. A small syntax mistake or conflicting rule can affect how your website loads.
Create a 301 Redirect in Htaccess
A 301 redirect tells browsers and search engines that a URL has permanently moved.
A common example is:
/old-page → /new-page
This is useful after changing a page slug, reorganizing website content, merging similar pages, or replacing an outdated URL.
For permanent changes, a 301 redirect htaccess rule is normally more appropriate than simply deleting the old page and allowing its URL to return an error.
The destination should still make sense for someone who wanted the original page. Don’t redirect unrelated URLs simply because you want them to lead somewhere.
Redirect an Old URL to a New URL
URL changes happen frequently during website updates.
You might change:
/seo-service
to:
/seo-services
Even though the difference looks small, these are two separate URLs.
If the old address has been indexed, bookmarked, shared, or linked from another website, removing it without a redirect can send those visitors to a 404 page.
An old URL to new URL redirect gives the previous address a clear destination and creates a smoother transition after the change.
Redirect One Page to Another Page
You don’t always need to redirect an entire website.
Sometimes only one page has moved.
For example:
/website-audit-service → /seo-audit
A single page htaccess redirect is useful when you:
- Rename a page
- Replace an outdated landing page
- Merge two closely related pages
- Change a WordPress permalink
- Move content to a cleaner URL
Whenever possible, send the old URL directly to the closest relevant replacement rather than to a generic homepage.
Redirect a Domain to Another Domain
If a website moves to a new domain, visitors may continue reaching the old one through search results, saved bookmarks, backlinks, or previously shared URLs.
An htaccess domain redirect can forward requests from the previous domain to the new website.
Where possible, preserve the page relationship.
For example:
olddomain.com/contact → newdomain.com/contact
is generally more useful than sending every old URL to:
newdomain.com
This helps visitors land where they expected to go.
Redirect HTTP to HTTPS Using Htaccess
After SSL is configured, a website may still be accessible through an old http:// address unless HTTPS forwarding is properly configured.
A typical setup redirects:
http://example.com/page
to:
https://example.com/page
An HTTP to HTTPS htaccess redirect keeps visitors on the secure version of the site and helps maintain one consistent URL format.
However, SSL must already be correctly installed. A redirect rule cannot replace an SSL certificate or repair an incorrectly configured HTTPS setup.
Redirect WWW to Non-WWW
A website can sometimes respond on both:
www.example.com
and
example.com
If the non-www version is your preferred format, requests to the www address can be redirected to it.
For example:
https://www.example.com/about
becomes:
https://example.com/about
A www to non-www htaccess redirect helps maintain a consistent URL structure across the site.
Redirect Non-WWW to WWW
The opposite configuration is also possible.
If your preferred website address includeswww, you can redirect:
https://example.com
to:
https://www.example.com
Neither format is automatically better simply because it contains or doesn’t contain www. What matters is choosing the version appropriate for your setup and using it consistently.
301 vs 302 Redirect: Know the Difference
Although both send visitors somewhere else, a 301 and 302 don’t communicate the same thing.
A 301 redirect is intended for a permanent move.
Use it when an old URL has been permanently replaced, and you expect the new destination to remain.
A 302 redirect represents a temporary move.
It may be appropriate when the original URL is expected to return later.
For routine permanent URL changes, don’t select a temporary redirect simply because both appear to work the same way in your browser.
Practical Htaccess Redirect Examples
Here are a few situations where redirect rules are particularly useful.
Changed page slug:
An article’s URL was shortened or renamed. Redirect the previous slug to the current one.
Deleted page with a replacement:
An old service page is removed, but a newer page covers the same purpose. Send users directly to that replacement.
Website moved to another domain:
Redirect old domain URLs to their corresponding pages on the new domain.
HTTPS migration:
Forward HTTP requests to their HTTPS equivalents after SSL has been configured.
Preferred domain version:
Choose either www or non-www and redirect the alternative version consistently.
These redirects solve different problems, so the correct rule depends on what has actually changed.
Where Do You Add Htaccess Redirect Rules?
On many Apache-hosted websites, .htaccess is located in the website’s root directory—the same general area where core site files are stored.
Because filenames beginning with a dot may be hidden, you might need to enable Show Hidden Files in your hosting file manager.
Before editing the file:
Download or save a copy of the existing .htaccess file.
Also avoid replacing the entire file just to add one redirect. Existing WordPress, security, caching, or hosting rules may already be present.
If your website uses Nginx or another server that doesn’t process .htaccess, these rules won’t apply.
Why Is My Htaccess Redirect Not Working?
A generated rule can be correct yet still fail due to the surrounding server configuration.
Common causes include:
- The rule was added to the wrong
.htaccessfile - Another redirect runs before it
- The old and new URLs create a redirect loop
- Apache rewriting isn’t available for the required rule
- A caching layer is showing an older response
- Existing WordPress or hosting rules conflict with the new redirect
- The source path doesn’t match the requested URL
If a redirect doesn’t behave as expected, remove the new rule temporarily and restore your backup if necessary.
Too Many Redirects
A browser may show a “too many redirects” message when one rule redirects to another, which then redirects back to the original URL.
For example:
Page A → Page B
Page B → Page A
That’s a redirect loop.
Review overlapping HTTPS, www/non-www, plugin, CDN, and .htaccess redirects if this happens.
500 Internal Server Error After Editing Htaccess
A malformed directive or unsupported configuration can cause a 500 Internal Server Error.
If the error appeared immediately after changing.htaccess, restore the previous version first. Then check the new rule before adding it again.
This is one reason keeping a backup takes only a few seconds but can save a lot of trouble.
Htaccess Redirects and SEO
Redirects become important for SEO when URLs that already receive traffic or links are changed.
A permanent redirect gives search engines and visitors a route from the previous URL to its replacement. But redirects should be relevant and intentional.
A few practices are worth following:
- Redirect an old page to its closest replacement.
- Avoid sending every deleted URL to the homepage.
- Keep redirect chains as short as possible.
- Update important internal links to point directly to new URLs.
- Don’t create multiple rules for the same URL.
- Test redirects after publishing them.
For example, this is cleaner:
Old URL → New URL
than:
Old URL → Another URL → Temporary URL → New URL
Direct redirects are easier to maintain and reduce unnecessary requests.
Generate Htaccess Redirect Rules Without Writing Them Manually
Most website owners don’t need to remember the Apache redirect syntax.
Htaccess Redirect Generator provides a more user-friendly option for creating common redirect rules for page moving, 301 redirects, domain changes, HTTP to HTTPS, or www/non-www options.
Create the rule, check the source and destination thoroughly, make a backup of your current .htaccess file, and make sure the redirect works once you’ve added it.
