I’d like my page to be displayed like whackamoley.epizy.com/home , not whackamoley.epizy.com/home.html
How do I do that? I can’t really find anything on google that works for me. Also, I’m not using php as I honestly have no clue how to write php. So php solutions won’t work.
None of the solutions work when I add it to .htaccess? (.htaccess in htdocs that I made not the og one that says “do not edit”
@Whackamoley add this into your .htaccess
file:
Options +MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
2 Likes
If you have any issues I will be happy to help
Hi, adding that doesn’t work.
please explain more than just ‘does not work’
Ok so I pasted it into my htaccess file. But when I access my website, and press a link that redirects to a different .html file. It still has its url as “file.html”
I’m probably making a stupid mistake here though, as I’m still relatively new to web development. Just not really sure what it is.
Add this code to your .htaccess:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+)$ $1.php [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.+)$ $1.html [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.htm -f
RewriteRule ^(.+)$ $1.htm [L,QSA]
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{THE_REQUEST} \/$|\.php\ HTTP [NC]
RewriteRule ^(.*)$ /404 [L]
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{THE_REQUEST} \/$|\.html\ HTTP [NC]
RewriteRule ^(.*)$ /404 [L]
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{THE_REQUEST} \/$|\.htm\ HTTP [NC]
RewriteRule ^(.*)$ /404 [L]
Make sure you have a 404.html or .htm or .php available.
What’s that for? When someone can’t find a page?
This is its full code:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} /([^.]+)\.html [NC]
RewriteRule ^ /%1 [NC,L,R]
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^ %{REQUEST_URI}.html [NC,L]
Just realized why it wasn’t working was because I was still linking them with .html or .php… But yeah your solution works!
1 Like
yep, but that is only for .html files.
system
Closed
September 29, 2020, 6:24pm
17
This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.