Hi All,
i wonder how to make a url with-out file extension .php or html?
example:
instead---> samsung.com/nz/consumer.php
here---> samsung.com/nz/consumer
url with-out file extension .php/.html?
Moderator: General Moderators
Re: url with-out file extension .php/.html?
A very simple change, if you're using Apache, is to enable MultiViews. In a .htaccess
That will let you omit the extension from any file type that Apache recognizes: at the very least .php, likely images and .css and .js and many others.
If you don't want that much then you need mod_rewrite.
Code: Select all
Options +MultiViewsIf you don't want that much then you need mod_rewrite.
Code: Select all
RewriteEngine on
# not a file
RewriteRule %{REQUEST_FILENAME} !-f
# not a directory
RewriteRule %{REQUEST_FILENAME} !-d
# is a file if you add a .php extension
RewriteRule %{REQUEST_FILENAME}.php -f
# add the extension and stop
RewriteRule $ .php [L]Re: url with-out file extension .php/.html?
Or you can use regexp and do it that way.
This is how I did mine.
Code: Select all
RewriteEngine On
RewriteBase /
RewriteRule ^([a-zA-Z0-9]+)+(|\/)$ file.php?page=$1- Kaleb Klein
------------------------------------
Web Developer | Software Developer
https://kalebklein.com
PGP Key: https://keybase.io/pazuzu156
------------------------------------
Web Developer | Software Developer
https://kalebklein.com
PGP Key: https://keybase.io/pazuzu156