• Hi, I’m brand new to WordPress and to the forum.
    My goal is to add a WordPress blog to my existing website. I have installed WP on my existing site in a directory named ‘blog’ under the root of the domain.
    Thus:
    https://www.mysite.com/ is the home page of my website
    https://www.mysite.com/blog/ is my blog’s main page

    However, when I try to add a post or edit the sample page all the preview links go directly to the home page of the website… instead of the page/post I’m trying to edit.

    I finally found that if I added this line to the .htaccess file at the root of the site:

    RewriteRule ^(/)?$ blog [L]

    … then, all my preview links and navigation on those pages worked perfectly. However, it also caused the link for https://www.mysite.com/ to be redirected to https://www.mysite.com/blog/ thus rendering the existing website unreachable.

    I can’t figure out how to edit the .htaccess file in order to make the existing website reachable AND allow the links for preview (and all the links to posts, etc. on the actual blog page) to be correct. I think I need to have this redirect in the .htaccess file and I’ve tried putting it in numerous places in this file, but haven’t hit on the solution.

    I’m sure it is something simple but I have not discovered it. I am using the Weaver II theme, if that makes any difference.

    Here is my complete current (root) .htaccess file. This version allows the main website to be seen at the domain address but all the blog editing links, etc. do not work properly (as described above):
    ——————————
    RewriteEngine on
    DirectoryIndex home.html
    IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*

    <Limit GET POST>
    order deny,allow
    deny from all
    allow from all
    </Limit>
    <Limit PUT DELETE>
    order deny,allow
    deny from all
    </Limit>
    AuthName mysite.com
    RewriteCond %{HTTP_HOST} ^mysite.com$ [OR]
    RewriteCond %{HTTP_HOST} ^www.mysite.com$
    RewriteRule ^denise\.html$ “https\:\/\/sec\.mysite\.com\/secmysite\/uploadform\.mgi” [R=301,L]

    # BEGIN WordPress

    # END WordPress
    ——————————

    Since I didn’t actually create this .htaccess file (i.e., Apache did via cPanel) I’m not too confident about simply changing any of it, and frankly I’m not sure what is needed, and what might not be needed.

    When I added the ‘RewriteRule ^(/)?$ blog [L]’ line, I added it above # BEGIN WordPress; I also tried it between # BEGIN WordPress and # END WordPress. Both of these make my links work but redirect away from my ‘home.html’ page as the domain address for the existing website.

    There is also a .htaccess file in my ‘blog’ directory, which simply shows:

    DirectoryIndex index.php

    I don’t see any other .htaccess files anywhere on this website.

    Any help will be most appreciated. Laughing and pointing is OK, too.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The best thing to do is to delete the .htaccess file, then in your admin area, go into ‘Settings -> Permalinks’ and set them again. This will re-generate your .htaccess file with the correct contents.

    Thread Starter subeeweb

    (@subeeweb)

    Thank you, michael.mariart. I just tried your suggestion but I can’t seem to make any settings in the permalinks which will allow the post to be accessed. In other words, all the current links are broken. My home page shows up but all the blog pages/posts get a 404 error. I can manually add the “/blog/” into the urls generated by the permalinks but can’t get it to write itself in without using the line below in my .htaccess file:

    RewriteRule ^(/)?$ blog [L]

    But this, as I mentioned, makes my home page unreachable since it redirects everything to the blog folder.

    I did try actually deleting all the posts and pages I already had, then creating a brand new one after 1) deleting the original .htaccess file and then 2) trying to set the permalinks as you suggested. Still, I couldn’t access the new post (got a 404). Although, the 404 message is the one within the theme and not the default Apache 404.

    This is what the newly created .htacess file shows:
    —————————-
    # 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
    ——————————-

    I tried pasting the /blog/ rewrite line, and other parts of the original .htaccess file into this new one, just to see if I could get anything magical to happen. No luck.

    Am I simply setting my permalinks incorrectly? It seems to me that the permalinks have more to do with the ‘filename’ of the post/page, rather than the ‘directory’. At this point I am not at all concerned with the ‘filename’ of the post… I simply want the /blog/ directory to be correctly inserted into all the links for the Edit previews links, and on the navigation links in the sidebar when viewing the actual post/page… plus, the home link needs to point to the main page of the existing website.

    Seems like it should be so simple…

    Thread Starter subeeweb

    (@subeeweb)

    A bit more information…

    When I installed WP on this site, I used Fantastico via cPanel to do the install; and per the instructions I let Fantastico create the ‘blog’ directory, and it was installed directly into that directory.

    In other words, I did not install it at the root and then move it, or install it into a pre-existing directory, nor have I changed the name of the ‘blog’ directory. This installation was the exact installation using Fantastico’s installer via cPanel.

    Just can’t figure out why it’s so screwy…

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Can't preview pages, all links go to home page’ is closed to new replies.