Web address of some web sites end with ".aspx", ".php", ".jsp", etc.How web developers can hide the extensions from visibility.

Dani AI

Generated

Short summary and context: as asked, the visible file extensions (.php, .aspx, .jsp) are normally removed by presenting extensionless URLs and mapping them to server-side resources. is correct that a server rewrite/routing feature is the right tool; ’s .htaccess is a common PHP shortcut and rightly clarifies that a rewrite creates a friendly URL that maps to the real file — it does not magically make the backend invisible. The generator link provided by can be a handy quick start, but production rules should follow server docs and be tested.

How it actually works: two common patterns exist — internal rewrite (the browser stays at /page while the server serves /page.php or /page.aspx) and external redirect (the browser is redirected to the canonical URL). For migration or canonicalization use 301 redirects from the non-preferred form to the preferred, and avoid treating extension removal as a security measure (server headers and app behavior still reveal platform).

Short, practical examples (do not overwrite static assets):

# nginx: pass missing paths to front controller (PHP frameworks)
location / {
    try_files $uri $uri/ /index.php?$args;
}
<!-- IIS (web.config) example: rewrite extensionless requests to .aspx when file/dir not present -->
<rule name="ExtlessToAspx" stopProcessing="true">
  <match url="^(.*)$" />
  <conditions>
    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
  </conditions>
  <action type="Rewrite" url="{R:1}.aspx" />
</rule>

Practical tips and pitfalls: exclude images/CSS/JS from rewrites; preserve query strings; avoid redirect loops; update internal links and sitemaps and use 301s for SEO; test with curl or browser dev tools and on staging before deploying. Extensionless URLs improve UX and SEO, but do not replace proper security, routing, or server hardening.

Recommended Answers

All 4 Replies

You can do this by using a rewrite module. For asp.net, its the URL Rewrite Module (or you can write a custom one), for php you'd use a .htaccess file with the rewrite rules, etc...

I thik for this you have to use .htaccessfil with some code in that.
here is exmple of php extensioncode:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^.]+)$ $1.php [NC,L]

First, confirm that the mod_rewrite component is set up. Then, be cautious to comprehend how it performs, many individuals get it in reverse.
You don't cover up web addresses or additions. What you do is make a NEW url that guides to the old one, for example
The URL to put on your website will be yoursite.com/play?m=asdf
or better yet
Even though the listing asdf does not are available. Then with mod_rewrite set up you put this in .htaccess. Generally it says, if the asked for URL is NOT a computer file and is NOT a listing, immediate it to my script

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.