To remove .html or .php from a URL, make the extensionless address canonical: permanently redirect the old address to it, then internally route that clean path to the file or application that serves the page. This is a server-routing change, not simply a file rename. “Extension” is the standard spelling.
How extensionless URLs work
Two separate actions are needed. A redirect tells the browser to request a different address, so visitors and search engines move from /page.html to /page. An internal rewrite routes a request for /page to the existing file or application handler without changing the address shown in the browser. Apache describes mod_rewrite as a way to modify incoming requests dynamically using regular-expression rules in its mod_rewrite introduction; its URL remapping guide distinguishes redirects from internal mapping and recommends a dedicated Redirect when available.
Keep the two operations distinct: redirect old extension-bearing URLs to the chosen clean form, then map clean requests internally. Without the redirect, both forms may remain accessible; without the internal mapping, the clean address may not resolve to the intended content.
Apache HTTP Server
Apache rules can be placed in server or virtual-host configuration, or in per-directory configuration such as .htaccess. The matching path differs by context: in server and virtual-host context, the pattern includes the URL path; in per-directory context, Apache strips the directory prefix before matching. Query strings are not part of a RewriteRule pattern. See the Apache introduction.
#1 Best Overall
A safe setup separates the permanent redirect from the internal mapping and checks that the target exists where appropriate. Apache’s extension-change example uses -f to test for the new file and !-f to test that the old file is absent, helping avoid collisions. The exact rule depends on whether pages are physical files or application routes, so adapt the paths to your site rather than pasting a generic rule blindly.
If rules are in .htaccess or a <Directory> block, verify the per-directory path base. Apache notes that RewriteBase may be needed when the URL path does not map directly beneath the document root; see the mod_rewrite directive documentation.
Rank #2
- HTML CSS Design and Build Web Sites
- Comes with secure packaging
- It can be a gift option
NGINX
In NGINX, use a permanent return 301 (or an equivalent permanent redirect) for the old extension URL, then route the clean path internally using a rewrite or a try_files-style fallback suited to the site’s file and application layout. NGINX’s rewrite module documentation describes return status codes and rewrite processing.
Rule order matters. NGINX processes rewrite directives in order; last stops the current rewrite sequence and begins a new location search, while break stops rewrite processing in the current context. Put canonical redirects before internal fallbacks and check that the resulting flow cannot loop. Refer to the NGINX rewrite module guide when choosing the directive behavior.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Scan for outdated or missing drivers - takes under a minute3Repair Windows errors before they cause bigger problemsQuick Recap
Best Value
Rank #4
- Brand: Wiley
- Set of 2 Volumes
- A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers
Rank #3
Apache and NGINX compared
| Concern | Apache HTTP Server | NGINX |
|---|---|---|
| Rule syntax | mod_rewrite uses a regular-expression pattern, substitution, and optional flags; query strings are not part of the pattern. Apache documentation |
rewrite uses a regular expression and replacement URI; return can issue a redirect. NGINX documentation |
| Where configured | Server or virtual-host configuration, or per-directory contexts such as .htaccess and <Directory>; the path used for matching depends on context. Apache introduction |
In NGINX configuration contexts using the rewrite module; directive order and location processing affect the result. NGINX documentation |
| Permanent redirect | A dedicated Redirect is the cleanest approach when server configuration access is available. Apache remapping guide |
Use return 301 or another appropriate permanent redirect. NGINX documentation |
| Internal mapping and safeguards | Keep the clean-path mapping internal; existence checks such as -f and !-f can help prevent collisions. Apache remapping guide |
Use an internal rewrite or try_files-style mapping matched to the site’s layout; last and break have different effects. NGINX documentation |
Test the change before relying on it
- Choose the canonical form. Decide on extensionless paths, one trailing-slash policy, and one scheme and host. Ensure other variants redirect to that same form.
- Check the old address. Request a page such as
/page.htmlor/page.php. It should return a permanent redirect to the intended clean URL, not serve duplicate content. - Check the clean address directly. Request
/pagein a fresh browser or HTTP client. It should serve the expected page while the browser continues to show the clean address. - Check edge cases. Test query strings, nested directories, assets, and a page whose target file does not exist. A missing target should return a genuine 404 rather than redirecting repeatedly or falling through to unrelated content.
- Review the configuration context and order. On Apache, confirm whether the rule is in server, virtual-host,
.htaccess, or<Directory>context and whetherRewriteBaseis needed. On NGINX, verify directive order and the effects oflastorbreak.
Common problems to avoid
- Renaming files without changing routing: removing a suffix from the visible address does not itself connect that address to the existing file or application.
- Keeping both versions live: redirect the old extension URL rather than serving the same page at two indexable addresses.
- Redirecting a clean URL back to itself: separate redirect and internal rewrite rules, and test the full request path to catch loops.
- Applying a rule too broadly: use existence checks or routing conditions suited to the site’s layout so that real files, application routes, and missing paths are handled intentionally.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




