Free URL Rewriting Tool – Generate .htaccess Rewrite Rules

تحسين محركات البحث

URL Rewriting Tool


ادخل الرابط



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

عن الموقع URL Rewriting Tool

Imagine sending a customer a link like product.php?id=42&cat=7. It opens the right page, but the address says nothing about the content, and the query string makes it look like a tracking link. A readable address such as /test-firstid-1-secondid-10.htm solves that, as long as the server knows how to map it to the script that already runs.

The URL Rewriting Tool on ONE SEO Tools generates the Apache rewrite rules that make this mapping work. You keep your existing script and publish the readable address. This guide covers the two patterns, how to upload the code, and what you still need to check yourself.

What the Tool Generates

The tool supports two patterns. Type 1 produces a single-page address that ends in .htm and carries two hyphen-separated values. Type 2 produces a folder-style address where each value sits between slashes. For each type, the page shows a generated URL, an example URL with placeholders such as (Any Value), and a block of .htaccess code.

The tool generates rule text and nothing more. It does not upload the file, update your internal links, create 301 redirects for old addresses, or confirm that your script handles the values the rule passes along.url rewriting

How to Set Up Your Rewrite Rules

  1. Choose a pattern. Use Type 1 for addresses that end in .htm, or Type 2 for folder paths.
  2. Read the Example URL row. The placeholders show which parts of the address the rule accepts, so confirm your script can handle those values.
  3. Copy the code block exactly as generated, including the backslash before the dot in the Type 1 rule.
  4. Create a plain text file named .htaccess, paste the code, and save it without an extra extension.
  5. Upload the file to the root folder of your domain, at the same level as your home page.
  6. Open one generated URL in a browser and confirm the page loads before you change any link.

Reading the Generated Code

The Type 1 block has two directives. Options +FollowSymLinks enables a feature mod_rewrite relies on, and RewriteEngine on turns the engine on. Some shared hosts restrict Options in .htaccess, so if you get a 500 error, ask your host whether per-directory overrides are allowed.

Options +FollowSymLinks
RewriteEngine on
RewriteRule test-firstid-(.*)-secondid-(.*)\.htm$ test.php?firstid=$1&secondid=$2

Each (.*) group captures the text in one position, and the rule passes it to test.php as $1 or $2. Visitors see the clean address while the server runs test.php?firstid=1&secondid=10. Because (.*) accepts any characters, the script should validate its inputs rather than rely on the rule to filter them.

Type 2 uses two rules, one matching the path with a trailing slash and one without, so both forms reach the page.

Options +FollowSymLinks
RewriteEngine on
RewriteRule test/firstid/(.*)/secondid/(.*)/ test.php?firstid=$1&secondid=$2
RewriteRule test/firstid/(.*)/secondid/(.*) test.php?firstid=$1&secondid=$2

Choosing Between Type 1 and Type 2

Type 1 suits flat collections of pages you want to look like files. Type 2 suits content grouped into categories, where the folders reflect the hierarchy.

Feature Type 1 Type 2
URL ending .htm Folder path with a trailing slash
Example /test-firstid-1-secondid-10.htm /test/firstid/1/secondid/10/
Best for Flat pages that should look like files Categorized content with a clear hierarchy

Tightening the Pattern by Hand

If your values are always numbers, you can restrict the match yourself. The anchors ^ and $ limit the rule to the full path, and [0-9]+ accepts digits only. The generated code does not include these restrictions, so test a manual version on a staging copy first. The Apache mod_rewrite documentation lists every directive and flag.

RewriteRule ^test-firstid-([0-9]+)-secondid-([0-9]+)\.htm$ test.php?firstid=$1&secondid=$2 [END]
RewriteRule ^test/firstid/([0-9]+)/secondid/([0-9]+)/?$ test.php?firstid=$1&secondid=$2 [END]

The [END] flag stops Apache from applying further rewrite rules after a match. Use it only on the rule that should run last.

Common Problems and Fixes

  • A 500 error after upload. Your host may not allow the Options directive, or the file has a syntax error. Remove the file, confirm the site loads, then compare your copy line by line with the generated code.
  • A clean URL shows a 404. Confirm the file sits in the domain root, the pattern matches the link exactly, and test.php exists.
  • The script receives wrong values. Parameter names in the rule must match the variables your script reads, such as $_GET['firstid'].
  • The rules conflict with a CMS. Many content management systems write their own rewrite block into .htaccess. Merge carefully and test afterward, because rule order determines which rule matches first.

What the Tool Does Not Do

The generator does not check that your server supports mod_rewrite, edit your pages, or create permanent redirects from old addresses. It also does not verify that the PHP script behind the rule is secure. Treat the output as a draft to review and test before it goes live.

Protecting Your Rankings During the Switch

Clean URLs do not improve rankings on their own. What protects your results is keeping each page's content and signals intact when its address changes. Start with a mapping sheet that pairs every old address with its new one. Each old page should return a permanent 301 redirect to its matching new page, not to the homepage, since sending everything to one page leaves visitors and search engines without the content they wanted. Google's guidance on 301 redirects explains how these pass signals to the new address.

After the switch, point internal links directly at the new addresses instead of relying on redirects. Update canonical tags, submit an updated XML sitemap, and look for redirect chains, where an old address takes two hops to arrive. Google's site move guidance covers these steps in more detail.

Then monitor the results. The Pages report in Google Search Console shows indexing problems, and the performance data shows whether clicks hold steady. The Google Index Checker can spot-check that new addresses are indexed, and the WWW Redirect Checker confirms that only one version of your domain resolves. To build the redirect rules, the HTAccess Redirect Generator is the natural next step.

Final Thoughts

Before switching any links, test one generated address, confirm your redirect map, and check the search data for several weeks afterward. Most problems show up in one of those three places.