WordPress.org

Ready to get started?Download WordPress

Forums

WP just blog in subdirectory (4 posts)

  1. omarmatijas
    Member
    Posted 2 years ago #

    First of all, a few things:
    -Im spanish speaker (sorry about my english)
    -I've first searched this issue (for 2 hours), but not found/understand any solution.

    I've developed a SEO friendly site for a friend, using .htaccess:
    ---
    Options -Indexes
    DirectoryIndex default.php

    Options +FollowSymLinks
    RewriteEngine on
    RewriteBase /

    # * * PRIMERA REGLA GESTOR: default
    Rewriterule ^cfg$ /gestor/default.php [R,L]

    # Directories to ignore.
    Rewriterule ^(|inc|img|gestor|jquery|)(/.*)?$ - [L]

    # Para que no ponga en la URL error.php, sino que quede la url ingresada
    Rewriterule ^error.php$ - [L]

    #evitar loops (al sacar extension y luego se la pone para el archivo real...)
    RewriteCond %{ENV:REDIRECT_STATUS} 200
    RewriteRule .* - [L]

    #External Redirect .php files to .html files (SEO friendly)
    RewriteRule ^(.*)\.php$ /$1 [R=301,L]

    Rewriterule ^class/(.*)$ /class.php?Url=$1 [L]

    #Internal Redirect .php files to .html files (SEO friendly)
    #Redirects all files that end in .html to be served from filename.php so it looks like all your pages are .html but really they are .php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ $1.php [L,QSA]
    ---

    Now my friend asked me to include a blog. I've been working with WP so i've installed WP in /blog/ subdirectory.
    Now i'm developing in localhost (with Wamp). So if i want to access to the blog, i have to delete all the content of .htaccess, and WP works just fine (http://localhost/blog/)
    But my original site its not working.
    When i restore .htaccess (that i put before) i get a 403 forbidden error in any WP page (including /wp-admin/)

    Hope i made myself clear. Thanks! Omar

  2. chreo at wp
    Member
    Posted 2 years ago #

    I am not that good at regular expressions, so I don't know exactly how to write it, but it seems to me that you could make conditional rewrites.
    Before the first condition about default.php, (because WP has index.php, doesn't work without it, can't be renamed if you don't want to rewrite every file in WP)
    start with this :
    if page has /blog/ in the address, no rewriting = the rest of the rewrites don't apply to anything in that subfolder.
    wp has its own .htaccess which defines how to NOT SHOW .php, but still read the .php-extension, so any other rule about this would be in conflict.

    You should also put as first rewrite condition that
    NOT yoursite/blog/ANYTHING .php
    and the following conditions
    yoursiteANYTHING .php

    That should send any request to your blogsite right through without rewrites.

  3. omarmatijas
    Member
    Posted 2 years ago #

    Thanks for answering.
    What i figured out its that the real problem is with WP home in my subdirectory.

    wwww.example.com/blog/
    Displays 403 Forbidden.

    On the other hand,categories, labels, posts & search works ok.

    I'll keep looking foward in previous topics.

  4. omarmatijas
    Member
    Posted 2 years ago #

    I DID IT!

    The problem was that my home page (www.example.com) was default.php and .htaccess said:

    DirectoryIndex default.php

    That generated error on blog/ subdirectory (WP instalation).
    I renamed default.php to index.php in my home site, changed htaccess and it was solved.

Topic Closed

This topic has been closed to new replies.

About this Topic