X RewriteRule Generator for Apache .htaccess
2021-05-25 All URL are expected to start with 'https'.
I hope this tool will help you.
Test your site once you are done with this
A simple solution is to create a simple html page on your site with only all the old links in it.
Add a link to this temporary test page in one of your page, e.g. in the sitemap, whatever.
Once you have finished your tests, just comment this link to hide it, ready for the next time.
If the old-url has an extension (.jpeg, .html) useless \/? characters are added after the extension.
Like in the example below, the URL ending by img_01.jpg.
URI specifications are very complex, specially with all the new .tld.
Generate - UnGenerate Apache .htaccess RewriteRule
- generate permanent 'RewriteRule' lines for Apache .htaccess file.
- un-generate 'RewriteRule' lines back to the original lines.
The lines format must be old-url comma new-url without space or tab.
The 'www.' in the old URL is optional.
The trailing / is optional.
TIP: Use a / at the end of an URL to avoid a second HTTP request to the server!
Do not forget to add in the .htaccess file:
- 'Rewrite on' before the generated lines
- 'RewriteCond' before each different domains 'RewriteRule' blocks.
More information about Apache
.htaccess file and mod_rewrite.
RewriteRule ^blue\/?$ "https\:\/\/www\.mysite\.com\/red" [R=301,L]
RewriteRule ^en\/cyan\/?$ "https\:\/\/www\.mysite\.com\/en\-uk\/cyan" [R=301,L]
RewriteRule ^pict\/img\_01\.jpg\/?$ "https\:\/\/www\.mysite\.com\/pict\/new\_door\.png" [R=301,L]
RewriteRule ^hello\.html\/?$ "https\:\/\/www\.mysite\.com\/welcome\.php" [R=301,L]
RewriteRule ^page01\/?$ "https\:\/\/www\.mysite\.com\/red\-shirts" [R=301,L]
Problems and suggestions are welcome.
Soon... delete duplicates, group lines by domain, sort...