I have a problem, when I'm on the homepage and want to go to a page, it says this:

continenten/.html on this server

How can I remove the / so it's continenten.html and not continenten/.html?

This is my .htaccess file so far:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.html [NC,L]
  • 1
    I would want to know why this is happening and fix that rather than fixing it after the fact with rewrite. We would need to know more about how this comes about. Is this from an incorrect link on your site? Or another site? Your sitemap? Are these requests for this resource? Please tell us more so that we understand.
    – closetnoc
    Commented May 24, 2015 at 14:44
  • here is a picture: gyazo.com/152c7feddf5928bde51f7161d2f89209 the problem is, got a "file".html and a directory named "file" in the same directory
    – Mat
    Commented May 24, 2015 at 15:05
  • Okay. I get part of it, but I was asking about whether there is a bad link being made somewhere on your site or another site? Are you seeing this in your log files? I was just saying that I would be addressing why this is happening if this was my site.
    – closetnoc
    Commented May 24, 2015 at 15:16
  • I re-read your first line of your question. It appears you have a bad link that you need to fix. Are you using CMS or blogging software for your site? If so, what is it??
    – closetnoc
    Commented May 24, 2015 at 15:29

1 Answer 1


You would seem to have a couple of problems. You are trying to implement extensionless URLs, but (as per your comment) you have file.html and a subdirectory called file in the same directory. Because of this mod_dir is automatically adding the slash onto the end of the URL and your .htaccess directives are copying this slash into the substitution, hence the erroneous slash in the rewritten URL (and presumably a 404).

One solution might be to simply disable slash redirects:

DirectorySlash Off

However, this might have other consequences, depending on how your site is structured. See: http://httpd.apache.org/docs/2.4/mod/mod_dir.html#directoryslash

Alternatively, you could change the pattern in your RewriteRule to exclude (forward) slashes as well. Although, this might also have implications if you have subdirectories, so it might need to be modified further:

RewriteRule ^([^/.]+)$ $1.html [NC,L]

I've simply changed your backslash to a (forward) slash. I'd also question whether you need the . (dot) in the character class? (The dot does not need to be backslash escaped in a character class, it carries no special meaning here.)

  • I was rather tired this morning and not paying as much attention to things as I normally do. You hit the nail on the head. While I was thinking there was an invalid link somewhere, you got what the OP was really trying to do which was not so apparent by the question. Perfect!!
    – closetnoc
    Commented May 24, 2015 at 22:07

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.