Question

.htaccess not removing file extensions

So here is the link in question: http://cybergamegear.com/cards-for-crypto.html

The setup of my .htaccess file is as follows:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html
ErrorDocument 404 /404.html

So it should be removing the .html part, but when you navigate to the link, it errors: http://cybergamegear.com/cards-for-crypto

Any thoughts or suggestions?


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

The rules look fine to me, so I’m suspecting that Apache isn’t reading the .htaccess file in the first place. That could happen if it is not configured to do so. Open your VirtualHost config (usually /etc/apache2/sites-enabled/file) and make sure AllowOverride is set to All like so:

     <Directory /var/www/html>
        Options FollowSymLinks
        AllowOverride all
        Require all granted
     </Directory>

Restart Apache so that the changes take effect.