Website Construction

how to remove .php .html from link

Submitted by Pretinhoa, , Thread ID: 148221

Thread Closed
Pretinhoa
Newbie
Level:
0
Reputation:
0
Posts:
19
Likes:
0
Credits:
0
29-10-2019, 07:37 AM
This post was last modified: 29-10-2019, 07:39 AM by Pretinhoa
#1
Ol, estou construindo um site e, sempre que acesso uma pgina, ela termina com html ou .php e vi alguns sites que no acontecem, ento existe alguma maneira de fazer a extenso "desaparecer"?

RE: how to remove .php .html from link

sudo rm rf
I need BTC donations
Level:
6
Reputation:
18
Posts:
438
Likes:
68
Credits:
233
29-10-2019, 07:44 AM
#2
if you are wanting to remove php or html from a url using htaccess then insert this code

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

##remove html from url
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.html [NC,L]

After entering this on your htaccess you can then serve pages without the extension.

For example with href tyou can simply use no file extension like below
<a href="http://example.com/wallpaper" title="wallpaper">wallpaper</a>

if you are hosting with godaddy and a few other hosts you made need to use multiviews

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

RE: how to remove .php .html from link

erdem21
Lurker
Level:
0
Reputation:
0
Posts:
6
Likes:
0
Credits:
8
04-12-2019, 11:12 AM
#3
RewriteCond% {REQUEST_FILENAME}! -D
RewriteCond% {REQUEST_FILENAME}! -F
RewriteRule ^ ([^ \.] +) $ $ 1.php [NC, L]

Users browsing this thread: 1 Guest(s)