I want to hide the URL of the files, for example: example.com/cadastro.php
would you have some way to leave just example.com? Or some other way, but do not show the full path.
Thank you.
I want to hide the URL of the files, for example: example.com/cadastro.php
would you have some way to leave just example.com? Or some other way, but do not show the full path.
Thank you.
On the client side, with JavaScript this is not possible at 100%.
You have two ways that are halfway, and that can serve what you want:
<iframe src="url_a_esconder.php" />
so you create a page within the page to hide the content.
window.history.pushState("", "", '/');
so re-write the url for the domain
Edit .htaccess
and put the code below
AddHandler application/x-httpd-php5 .htm
AddHandler application/x-httpd-php5 .html
AddHandler application/x-httpd-php5 .shtml
AddHandler application/x-httpd-php5 .php
to hide .html
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html
to hide .php
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
If it is in the URL of the Browser, one of the options that you can leave configured in your site is the Friendly URL, using .htaccess (for apache) and web.config (for IIS)
.htaccess example
Example with simple page (No $ _GET) - In your case
RewriteRule ^$ ./cadastro.php
From: /cadastro.php
To: / = (site url)
Example with page with 1 $ _GET
RewriteRule ^u/(..*)$ ./u.php?rl=$1
From: /u.php?rl=CPosmA3gev
To: / u / CPosmA3gev
Example with page with + 1 $ _GET
RewriteRule ^pagina-(..*)-(..*)$ ./pagina.php?id=$1&outro=$2
From: / page? id = 1 & other = 2
To: / page-1-2
There is no difference in the formatting of the new url, so I used / and - to show how it works.
If you'd like a complete .htacces example, I'll leave one of mine here: link