• I am trying to move my WP installation from my /blog folder to my root directory. WP has an .htaccess and I also have a custom .htaccess file. I was trying to figure out by searching online if the order of things in the .htaccess file matters, but was unable to do so.

    If someone could help me out by helping me figure out how to structure my merged .htaccess file I would really appreciate it.

    My file (removes www from domain in address bar):

    RewriteEngine on
    Options +FollowSymlinks
    RewriteCond %{HTTP_HOST} ^www\.domain.tld [NC]
    RewriteRule ^(.*) https://domain.tld/$1 [L,R=301]

    WP file (don’t know what this does):

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

    If I had to guess what is correct, I’d guess this (but I’m afraid to just do it and load i up in case it screws up something — could it?):

    RewriteEngine on
    Options +FollowSymlinks
    RewriteCond %{HTTP_HOST} ^www\.domain.tld [NC]
    RewriteRule ^(.*) https://domain.tld/$1 [L,R=301]
    
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteBase /blog/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /blog/index.php [L]
    </IfModule>
    # END WordPress

Viewing 1 replies (of 1 total)
  • Thread Starter charlieholder

    (@charlieholder)

    Got this working. Was able to figure it out based on random tutorials about doing .htaccess.

    Now my question is:
    Does this part of the .htaccess file

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

    have anything to do with why visiting domain.td/d or domain.tld/q redirects to a specific post? I checked the post slugs and none of them are set to single characters. If I create a folder d or folder q, and it doesn’t have an index file, I’d still want it to go there and not some random post.

    Thanks.

Viewing 1 replies (of 1 total)
  • The topic ‘Combing .htaccess files’ is closed to new replies.