Forums

trouble with htaccess file (7 posts)

  1. ger01
    Member
    Posted 1 year ago #

    Hi,

    I didn't have a .htacces file but created one to enable pretty urls, I created a custom structure and then pasted the code that WordPress generated into my .htaccess. However now, images in my header.php and footer.php only display on my homepage, they do not display on any other page. Before I created the file all my header and footer images displayed correctly!

    .htaccess code looks like this:
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

    Is there a specific location where I should locate the .htaccess file? Do I have something missing from the file? Any help would be great! Thanks!

  2. elfin
    Moderator
    Posted 1 year ago #

    link to site please, and where did you place the htaccess file?

  3. datasoftict
    Member
    Posted 1 year ago #

    Are you on a windows server?

  4. ger01
    Member
    Posted 1 year ago #

    link to site please, and where did you place the htaccess file?

    Can I PM you the link as the site is still under development.

    This is where I currently have .htaccess
    httpdocs > mywebsite >
    .protect
    wp-admin
    wp-content
    wp-includes
    .htaccess

    I have another WP website in httpdocs as well, if that makes any difference.

    Are you on a windows server?

    No I'm on a Linux server

  5. elfin
    Moderator
    Posted 1 year ago #

    You are in a sub directory therefors your htaccess should look like this (I think):

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

    # 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

    If I use this for my .htaccess and have Default permalink settings selected it all works ok, but if I change the setting to anything other than default, images in my header.php and footer.php still do not display on all pages except for the homepage.

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

    If I use the code above, everything works as it should when I have default selected, however once I select anything other than default I get a 500 Internal Server Error!!

    :-(

  7. datasoftict
    Member
    Posted 1 year ago #

    I have a very distant memory that starting the rewrite rule twice is an issue, the rewrite engine should be on from the first pass of .htaccess in the root folder. Could be wrong on this, as I say just a memory from another issue I had with a demo site under our main site years ago. I don't have that site any longer so I can't go and check - sorry.

Topic Closed

This topic has been closed to new replies.

About this Topic