HTACCESS Redirect Generator
Generate HTACCESS Redirects
HTACCESS Redirect Generator
HTACCESS Redirect Generator is a useful tool that helps you generate the configuration code that could be added to the .htaccess file on an Apache Web server to handle page or site redirects.
How to Use
To generate the code enter the following parameters:
From Page - the old URL-path beginning with a slash (“/old-page”).
To Page - the new URL which may be either an absolute URL beginning with a scheme and hostname (“http://example.com”), or a URL-path beginning with a slash (“/new-page”).
Status Code - the HTTP status code to be send with the redirect:
- permanent - Returns a permanent redirect status (301) indicating that the resource has moved permanently.
- temp - Returns a temporary redirect status (302).
- seeother - Returns a "See Other" status (303) indicating that the resource has been replaced.
- gone - Returns a "Gone" status (410) indicating that the resource has been permanently removed. When this status is used the “To Page” argument should be omitted.
Here is an example of the code generated by the tool:
<IfModule mod_alias.c> Redirect 301 /old-page /new-page </IfModule>
The Redirect directive maps an old URL into a new one by asking the web browser to request the page at the new location.
The <IfModule> directive is not strictly required for the mod_alias module. The purpose of <IfModule> is to conditionally execute configuration directives based on whether a specific module is loaded or not.
If you are confident that mod_alias is always enabled on your server and you don't anticipate moving your configuration files to servers with different module setups, you can omit the <IfModule> lines for mod_alias.
However, if you want to ensure that your configuration is portable and can work on servers with different configurations, you may include <IfModule>.
Including <IfModule> is a good practice for portability, but the decision to use it depends on your specific use case and the level of control you have over the server configurations.
Using quotes around the path-URLs is generally optional, and both quoted and unquoted versions should work. However, it's a good practice to use quotes, especially when the path contains special characters or spaces.
The Redirect directive is designed to perform simple URL manipulation tasks. For more complicated transformations such as manipulating the query string, use the tools provided by mod_rewrite.
See Also:
mod_alias - Apache HTTP Server Version 2.4
mod_rewrite - Apache HTTP Server Version 2.4
IANA Hypertext Transfer Protocol (HTTP) Status Code Registry
Related Tools
Contact
Missing something?
Feel free to request missing tools or give some feedback using our contact form.
Contact Us