File extensions appear in test site :-(

Hi from clear blue skies York UK,

Ive created a test subdomain for a site i’m building and here is an example:

but I notice you have to have the .html on the end of the url, the page will not render with:

Why is this please? When i finally get to upload the test outside the sub domain will this problem go away?

Thanks,
David

How is the browser going to know what type of file it is without the extension? Do you have other sites that do not need the extension?

You should be able to add something to the .htaccess file so it renders all pages without an extension as html.

You can search the web for this and get some tutorials: htaccess remove page extension.

I did try this years ago and it did not work for me; it may have been the way the server was setup. I have not tried it since.

1 Like

The links are broken so I’m guessing this is a WordPress site?
If so, if you post the permalink rules that are in the htaccess file it might help

Apologies the links are now fixed (Meddled with the A records). http://test.davidclick.com/test/blog-stories.html

If your web server is Apache you can use mod_rewrite to hide extensions of static .html files
To do that make sure that mod_rewrite is enabled (ask hosting support if you don’t know how to check it) and create .htaccess (starts with dot) file in the root of your site. Then put this into that file:

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

After that you should be able to open /index.html as /index and so on.

1 Like

thankyou so much for this, i’ll take a crack at this sometime nxt wk :slight_smile:

Nw,

Use caution with mega’s code as, without the second RewriteCond, the :fire: EVERYTHING :fire: atom in the RewriteRule could redirect to http://example.com/.html. IMHO, better to use:

RewriteEngine on RewriteCond %{REQUEST_FILENAME}.html -f RewriteRule .? %{REQUEST_URI}.html [L]

Note that I did not make the test for “not a directory”, I did not need to escape the dot character in the second RewriteCond statement and I don’t care what the :fire: EVERYTHING :fire: atom captured because it was already contained in the {REQUEST_URI} variable.

More on mod_rewrite in a tutorial with abundant every day examples at http://dk.co.nz/seo.

Regards,

DK

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.