2

I have the following .htaccess file on my website for removing extensions:

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

This works perfectly on localhost, however, when I upload the file to GoDaddy and try to visit a URL, say mysite.com/page, Google Chrome automatically adds a trailing slash to the URL (just on the website, not on localhost). I'm assuming this causes the site to assume that page is a folder/directory and not a file? Is this what's happening? If so, what would be the best way to tackle the issue? Should I add to my .htaccess to automatically remove trailing slashes, or should I maybe have each page as a directory each with an index.php? What's the most efficient method?

1 Answer 1

1

It is possible to enforce no trailing slash if it is not a folder.

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.