I'm using this code
# Apache Rewrite Rules
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
# Add trailing slash to url
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/|#(.*))$
RewriteRule ^(.*)$ $1/ [R=301,L]
# Remove .php-extension from url
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^([^\.]+)/$ $1.php
# End of Apache Rewrite Rules
</IfModule>
It doesn't hide .php extensions from my pages, when I remove '.php' from my anchor tags, the page get redirected.
For eg. if url is www.example.com/mysite/store.php
and when I remove '.php' from URI or anchor href, the new url becomes www.example.com/store/
which is not available off course. I tried to manually enter url as example.com/mysite/store
but it is unavailable too.
Apparently .htaccess is not using these rules, if I write gibberish there, get a 500 server error, so .htaccess is working fine but what wrong is I'm doing.
Advice. Thanks in advice!
Update
Okay, I've figured it out, I successfully achieved what I asked in question. But my bootsrap is completely broken, I guess because it is linking 'bootstrap.css' as 'bootstrap.css.php' because the .htaccess file I'm now using is :
# Turn on the rewrite engine
RewriteEngine on
# If the request doesn't end in .php (Case insensitive) continue processing rules
RewriteCond %{REQUEST_URI} !\.php$ [NC]
# If the request doesn't end in a slash continue processing the rules
RewriteCond %{REQUEST_URI} [^/]$
# Rewrite the request with a .php extension. L means this is the 'Last' rule
RewriteRule ^(.*)$ $1.php [L]
DefaultType application/x-httpd-php
DirectoryIndex index.php index.html
Update 2
Sorry, this was not the problem as I mentioned in last update as after I stripped the bootstrap links in my index.php, I got different results. The problem is: localhost/example/index.php
is my homepage but localhost/example is what is shown in url. localhost/example
is a directory with files in it. So images that should be loaded as localhost/example/image/logo.png
is loaded as localhost/example/index.php/image/logo.png
making example site behave weird.