URL Rewriting Tool: Free htaccess Generator

URL Rewriting Tool

Enter a URL

E.g. http://www.example.com/test.php?firstid=1&secondid=10

This URL rewriting tool turns a dynamic URL with query parameters, such as test.php?firstid=1&secondid=10, into two clean URL styles and generates the matching Apache .htaccess rewrite rules. It is built for site owners and developers who want readable, search-friendly addresses without writing mod_rewrite patterns by hand.

What Is URL Rewriting?

URL rewriting is a server-side technique that lets a clean, readable address load a page that is actually produced by a script with query parameters. Visitors and search engines see the clean address, while the server quietly maps it back to the dynamic one.

A dynamic URL has a question mark followed by name and value pairs, for example product.php?cat=5&id=42. The same page could be reached at product-cat-5-id-42.htm or product/cat/5/id/42/. Both are easier to read, say aloud and share than the original.

Google's Search Central documentation recommends simple, descriptive URLs that people can understand, and advises against long strings of parameters where you can avoid them. Clean URLs do not guarantee higher rankings, but they make links more trustworthy-looking and easier to read in search results, chats and bookmarks.

How to Use the URL Rewriting Tool

You only need one input: the full dynamic URL of a page on your site. The steps below match the form on this page.

  1. Open the page and find the field labeled Dynamic URL.
  2. Paste your address, for example http://www.example.com/test.php?firstid=1&secondid=10. If you leave off the protocol, the tool assumes http. If you start with https, it keeps https.
  3. Submit the form with the main button.
  4. Review the two options shown on the results page. Each one lists the generated URL, a pattern example with "(Any Value)" in place of the real values, and a box of rewrite rules.
  5. Press the Copy button above the rules for the style you prefer.
  6. Paste the rules into the .htaccess file in the folder named in the instructions on the results page, then test a clean URL in your browser.

To convert another address, use the link on the results page to start again.

Worked Example: From Parameters to Clean URLs

Take the sample address http://www.example.com/test.php?firstid=1&secondid=10. The tool reads the script name (test.php), the name without its extension (test) and the two parameters (firstid and secondid).

Option 1: single-file style

The generated URL is test-firstid-1-secondid-10.htm. The pattern example reads test-firstid-(Any Value)-secondid-(Any Value).htm, which tells you any values will work in those positions. The rules begin with Options +FollowSymLinks and RewriteEngine on, then add one line: RewriteRule test-firstid-(.*)-secondid-(.*)\.htm$ test.php?firstid=$1&secondid=$2.

Option 2: folder style

The generated URL is test/firstid/1/secondid/10/. The rules use the same two opening lines, then two rewrite lines: one that matches the address with a trailing slash and one that matches it without. Both send the visitor to test.php?firstid=$1&secondid=$2.

Each (.*) captures a value from the clean address, and $1 and $2 place those values back into the query string in order. So a request for test-firstid-7-secondid-300.htm runs test.php with firstid=7 and secondid=300.

FeatureSingle-file styleFolder style
SeparatorHyphensSlashes
Ending.htm extensionTrailing slash
Rules generatedOne rewrite lineTwo rewrite lines

How Do You Read and Act on the Results?

Each result gives you a clean URL to publish and a block of rules that makes it work. Reading them correctly saves you from the most common setup errors.

  • The generated URL shows exactly how your page will look after the rules are active. Use it as the address in your menus, sitemaps and internal links.
  • The pattern example shows which parts are fixed (the script name and parameter names) and which parts change (the values).
  • The rules box is ready to paste. It targets the script file from your original address, so keep the .htaccess file in the same folder as that script.

A good result is a short, readable address with only a few parameters. A poor result is one with five or six parameters, such as list.php?a=1&b=2&c=3&d=4&e=5, because the clean URL becomes just as long and hard to read as the original. In that case, consider simplifying the parameters in your application first.

Choose the single-file style when you want addresses that look like static pages. Choose the folder style when you want a tidy hierarchy and a trailing slash. Pick one style per script and stay consistent, so the same page is not reachable under several different clean addresses.

How to Rewrite a URL in Apache, Nginx or IIS

On Apache, you rewrite a URL by enabling the rewrite engine and adding a rewrite rule in the .htaccess file or the server configuration. This tool writes those Apache rules for you.

Nginx and IIS use different syntax, so the pasted block will not work there as is. Nginx uses its own rewrite directive inside the server configuration. IIS uses its URL Rewrite module, with rules stored in the site's web.config file. You can still use this tool's output as a guide: the pattern in brackets and the target script with its parameters show you what to recreate in the other format.

On Apache, the server must have mod_rewrite enabled and your hosting must allow .htaccess overrides. Most shared hosts do. If the rules have no effect, ask your host to confirm both settings.

Is This the Same as URL Rewriting in Java or Session Tracking?

No. In Java servlets, "URL rewriting" usually means appending a session ID to a link so the server can track a visitor who has cookies disabled. That is session management, not SEO.

This page deals with the other meaning: turning parameter-heavy addresses into clean ones. If you searched for servlet or session tracking, this tool will not generate that kind of code.

Who Benefits from a URL Rewriting Tool?

Anyone who runs a site that exposes query strings in its public addresses can use it. The common cases are specific.

  • Small business and blog owners with a custom PHP script that outputs addresses like page.php?id=12.
  • Developers who want a quick, correct starting rule instead of working out capture groups from memory.
  • SEO specialists auditing a site that has long parameter URLs and need a clean pattern to hand to the development team.
  • Students learning how mod_rewrite maps a pattern to a target, who can compare the pattern example with the generated rule.

Best Practices, Common Mistakes and Troubleshooting

Most problems come from the input, the file location or the way old links are handled. Check these points first.

Enter a URL that has a query string

The tool only works with dynamic URLs. If you paste http://www.example.com/about.php with no question mark and parameters, you will see a message saying the address does not look dynamic. Add at least one parameter and submit again. If the address is not valid at all, you will see an error asking you to check it.

Put the rules in the right place

The rules refer to the script by filename, so the .htaccess file belongs in the same folder as that script. If your script lives in a subfolder and you paste the rules in the site root, the clean URL will return a 404 error.

Update your links

The rules make the clean address work, but they do not change the links on your pages. Edit your navigation, internal links and sitemap to use the new address. Use a tool such as the URL encoder and decoder when a parameter value contains spaces or special characters that must be encoded.

Handle old URLs deliberately

The old dynamic address keeps working after you add the rules, so the same content can load at two addresses. To avoid duplicate versions in search results, add a canonical tag pointing to the clean URL, or set up a 301 redirect from the old address. The generated rules do not include redirects.

Test before you publish

Back up your current .htaccess file, paste the new rules, then load a real clean address in a browser. A 500 error usually means a typo or a server that does not allow the Options line. Restore the backup and ask your host which directives are permitted.

Limitations and Accuracy Notes

The tool generates rules for Apache only, and it builds them from the one example URL you supply. It treats every parameter value as a wildcard, so the rules accept any value in those positions. Your script should still validate what it receives.

Values that contain hyphens or slashes can be ambiguous in the single-file style, because the pattern matches loosely. If your values are plain numbers or simple words, this is rarely a problem. If they are not, test several real examples before going live.

The output keeps your parameter names in the clean address, such as firstid and secondid. For fully descriptive addresses like /shoes/running/, you will need to adjust the rules or change how your application builds links.

Once your clean addresses are live, you can share them easily, and a URL shortener or bulk URL shortener helps when you need compact links for social posts. You can find more helpers in the online calculators and utilities category.

Paste your own dynamic address into the form above, pick the style you like, copy the rules and test them on your server. In a couple of minutes you can replace a parameter-heavy link with one that people can read and remember.

Frequently Asked Questions

What is URL rewriting?
URL rewriting is a server technique that maps a clean, readable address to a script that uses query parameters. For example, test-firstid-1-secondid-10.htm can load test.php?firstid=1&secondid=10. Visitors see the tidy address, and the server handles the translation.
How do I rewrite a URL in Apache?
Enable the rewrite engine and add a rewrite rule to your .htaccess file. This tool generates those rules from your dynamic URL, so you copy them into the .htaccess file in the same folder as your script and then test the new address.
What URL can I enter in the URL rewriting tool?
Enter a full dynamic URL that contains a question mark and at least one parameter, such as test.php?firstid=1&secondid=10. An address without a query string shows a message that it does not look dynamic, so add a parameter and try again.
Will URL rewriting break my existing links?
No, the generated rules do not remove your old dynamic address, so existing links keep working. They also do not add redirects. To avoid duplicate versions in search, add a canonical tag or a separate 301 redirect to the clean URL.
Can I use the generated rules on Nginx or IIS?
Not directly. The output is written for Apache .htaccess files. Nginx uses its own rewrite directive and IIS uses its URL Rewrite module, but the pattern and target script shown in the results can guide you when recreating the rule.
Is the URL rewriting tool free to use?
Yes, the tool is free and requires no sign-in. Paste your dynamic URL, review the two clean URL styles, and use the Copy button to take the rewrite rules for the style you prefer.
Recommended

Explore VPN options

A VPN changes your network exit. It does not guarantee anonymity.

Hide Your IP Encryption Network coverage
Protect My IP Now