GenerateIt

Mod Rewrite Generator

The Mod Rewrite Generator is designed to help you convert long, complex dynamic URLs into clean, search-engine-friendly static URLs. Static URLs are generally preferred by search engines because they are easier to crawl, index, and understand. They also tend to look cleaner and more trustworthy to users compared to dynamic URLs filled with multiple parameters and query strings.

This tool works by generating rewrite rules for the Apache mod_rewrite module, which allows URLs in one format to be transparently rewritten into another. mod_rewrite is especially useful for websites that rely on dynamic content, such as those powered by databases or content management systems, as it helps present that content in a format that search engines can more easily process.

By using this generator, you can quickly transform lengthy dynamic URLs into short, readable static URLs without changing how your site functions behind the scenes. The result is improved search engine visibility, cleaner links for sharing, and a better overall experience for both users and search engines.

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong.

Buy me a coffee

Enter your dynamic URL and click Rewrite URL to generate your new URL:

For example, you may enter the URL:
https://www.domain.com/cgi-bin/shop.php?cmd=product&category=vehicles&product=bus
and transform it into
https://www.domain.com/shop/vehicles/bus.html

Your URL is turned into a rule in your browser and is never sent anywhere. Always test a new rule on a copy of your site first.

How to use it

The mod rewrite generator is a great tool to assist you in creating mod rewrite rules for your htaccess file.

  1. Paste your URLCopy and paste a dynamic url into the text box above.
  2. Rewrite itClick on ‘Rewrite URL’ for options and code for your htaccess file.
  3. CustomizeYou now have options where you can change parameters, prefix, delimiters and suffix.
  4. Check the new URLThe generated URL and the rule update as you change the options.
  5. Copy the ruleThe rewrite rule is generated, which you can copy and paste into your htaccess file.

Adding the rule to your site

  1. Find your .htaccessFirst you need to check if the file .htaccess exists in the root of your website.
  2. If it existsDownload it from your site, add the lines to the end of the file, and upload the modified file back to your site. Please make a copy of the original file first, so if anything goes wrong, you may restore it.
  3. If it does not existCreate a new file .htaccess and add the lines to it. Then upload it to the root of your website. You may delete it if anything goes wrong.

Tips

Keep keywords

Do not include names of the parameters unless the name is a keyword. Include all the values unless one is always the same.

Avoid many slashes

Too many slashes reduce the relevance of the URL, and a dash is better than an underscore for separating keywords.

Test before you rely on it

Add the rule, open the new URL, and check that the right page loads. Keep a copy of your original .htaccess.

Frequently asked questions

Does the rule change the old URL into the new one?

No. The rule makes the new, clean address work: when a visitor (or search engine) asks for the new URL, your server quietly loads the old dynamic page. Links on your site need to be changed to the new addresses yourself. To send the old address to the new one, add a separate 301 redirect.

Where do I put the rule?

In the .htaccess file in the root folder of your site, on a server running Apache. Make a copy of the file first, then add the lines at the end. Your host must have mod_rewrite and AllowOverride turned on, which most do.

What do “Value”, “Name & value” and “None” mean?

Value puts only the value in the new address (/vehicles/). Name & value puts both (/category-vehicles), useful when the name is a keyword. None leaves the parameter out, and the rule then passes its original value on every time, so use it only for parameters that never change.

Which delimiter should I use?

Dashes are best for search engines. Pick one that does not appear inside your values, such as a dash when a value is “red-car”, or the rule cannot tell where one value ends.

I get a 500 error after adding the rule. What now?

Remove the Options +FollowSymLinks line, because some hosts do not allow it. If the error stays, restore your copy of the file and ask your host whether mod_rewrite is on.

Does it work on Nginx?

Yes. The Nginx line goes inside your server block, then reload Nginx. Nginx does not use .htaccess files.

Is my URL sent anywhere?

No. The rule is made in your browser.

Related tools

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong.

Buy me a coffee