Ultra Web Hosting

.htaccess Rewrite Rule Generator

Generate Apache mod_rewrite rules for clean URLs, HTTPS redirects, www redirects, custom error pages, hotlink protection, and more. Build .htaccess rules without memorizing regex.

.htaccess Rewrite Rule Generator

Generate common Apache .htaccess rules without memorizing mod_rewrite regex syntax. Select what you need below, fill in the details, and copy the generated rules into your .htaccess file.
Force HTTPS Redirect
Ensures all visitors use a secure HTTPS connection. Required for SSL certificates to work properly.
WWW / Non-WWW Redirect
Pick one and stick with it — having both versions accessible creates duplicate content issues for search engines.
Custom Error Pages
Point visitors to friendly error pages instead of generic server messages.
Clean URL Rewrite (Dynamic → Static)
Maps a clean, readable URL to your real PHP script with query parameters. The clean URL values replace the parameter values in order. Example: /products/shoes/42 rewrites to product.php?category=shoes&id=42
301 Permanent Redirect
Use 301 redirects when a page has permanently moved. This transfers SEO value (link juice) from the old URL to the new one.
Block Image Hotlinking
Prevents other websites from embedding your images directly, which steals your server bandwidth.
Security Headers
Security headers protect your visitors from common web attacks. Recommended for all sites, especially those using HTTPS.
GZIP Compression & Browser Caching
Compression makes files smaller for faster downloads. Browser caching prevents repeat downloads of images, CSS, and JS. Note: if you use NGINX caching on Ultra Web Hosting, GZIP is already handled at the NGINX layer.
Directory & File Security
Prevents visitors from browsing your directory structure and accessing sensitive files.

 

 

About This Tool

Clean, readable URLs are better for both users and search engines. Instead of a URL like "page.php?id=123&cat=4", a rewritten URL like "/products/widgets" is easier to read, share, and remember. Apache mod_rewrite rules, placed in your .htaccess file, handle this translation transparently. This generator creates the correct RewriteRule syntax so you do not have to learn the complex regex patterns yourself.

How to Use

Enter your original URL pattern and the clean URL you want visitors to use. The tool generates the appropriate Apache mod_rewrite rules that you can paste into your .htaccess file in the root of your website.

Tips & Best Practices

Always include "RewriteEngine On" at the top of your .htaccess file before any rewrite rules. Test your rules on a staging environment before deploying to production. A syntax error in .htaccess can take down your entire site. If you are on Ultra Web Hosting with NGINX caching enabled, note that .htaccess rewrite rules are processed by Apache behind the NGINX reverse proxy, so they still work normally.

Need reliable hosting? These free tools are brought to you by Ultra Web Hosting. Fast, secure shared and reseller hosting with 24/7 expert support. View hosting plans →