• I have a site that was a self-coded HTML site with a WordPress blog attached. I am in the process of changing it over to a fully WordPress site, intending over time to convert all my HTML pages to WP pages.

    I have successfully set it up so that my WP static home page is in the root directory and is the home page for the whole site. This required me to use the WP .htaccess file as the site .htaccess file

    There is one problem with this. My old site .htaccess file had some content in it to (among other things) allow alternative URLs (https://www. sitename, https://sitename, sitename/index.html, sitename/index.shtml and sitename/index.php to all be recognised and accepted. Visitors or links with any of these configurations would be able to reach the site.

    I have copied these lines of code from the old .htaccess file to the new one, but they don’t seem to work, whether I put them after the WP code (which starts with #BEGIN WordPress and ends with #END WordPress) or before it.

    Is there any trick to this that I need to know please?

    Site is https://www.is-there-a-god.info

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi,

    You could add the below lines in your .htaccess file:

    RewriteCond %{THE_REQUEST} ^.*/index.html
    RewriteRule ^(.*)index.html$ https://www.is-there-a-god.info/ [R=301,L]

    Adding these right after RewriteBase should work. You can add similarly for .shtml or any other extension.

    :Vishal

    Thread Starter unklee

    (@unklee)

    Thanks, I’ll give it a try.

    Thread Starter unklee

    (@unklee)

    I’ve been looking at this a little more, and I’m sorry, but I realise I don’t understand what you are suggesting. Let me clarify a little more.

    The WordPress-generated .htaccess file has the following:

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress

    Because for a while yet my site will be a hybrid WordPress/HTML site, I need some some 301 redirects for when HTML pages become WP pages and the URL changes, and a DirectoryIndex command to identify the change in home page from .shtml to .php. I also used to have the following .htaccess file, most of which I think I will still need for a while (although most things seem to be working OK without these extra commands):

    Options +Includes
    
    AddType text/html .shtml
    AddHandler server-parsed .shtml
    
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^is-there-a-god.info [NC]
    RewriteRule ^(.*)$ https://www.is-there-a-god.info/$1 [L,R=301,NC]
    
    <Files .htaccess>
      order allow,deny
      deny from all
      </Files>

    This seems to be more than you are allowing for here. Are you saying I should put all my commands in the place you indicate?

    Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Combine .htaccess file for HTML and WordPress’ is closed to new replies.