1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Using Wordpress in a subdirectory

Discussion in 'General XenForo Discussion and Feedback' started by BamaStangGuy, Feb 23, 2013.

  1. BamaStangGuy

    BamaStangGuy Well-Known Member

    I have a site that has xenForo in the root and will have wordpress in a subdirectory (domain/wordpress/ for example)

    However, when I use permalinks in wordpress xenForo tries to handle them. How do I get around this?
     
  2. Slavik

    Slavik XenForo Moderator Staff Member

    RewriteRule ^wordpress - [L]


    Put that before any other rewrite rules.
     
    havanaclub likes this.
  3. BamaStangGuy

    BamaStangGuy Well-Known Member

    Not working still

    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} !^www\.shottalk\.com
    RewriteRule (.*) http://www.shottalk.com/$1 [L,R=301]
    RewriteRule ^store - [L]
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -l [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^.*$ - [NC,L]
    RewriteRule ^(data/|js/|styles/|install/|favicon\.ico|crossdomain\.xml|robots\.txt) - [NC,L]
    RewriteRule ^.*$ index.php [NC,L]


    You can try it here: http://www.shottalk.com/store/
     
  4. Slavik

    Slavik XenForo Moderator Staff Member

    Hmm, maybe something like

    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_URI} "/store/
    RewriteRule (.*) $1 [L]
    RewriteCond %{HTTP_HOST} !^www\.shottalk\.com
    RewriteRule (.*) http://www.shottalk.com/$1 [L,R=301]
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -l [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^.*$ - [NC,L]
    RewriteRule ^(data/|js/|styles/|install/|favicon\.ico|crossdomain\.xml|robots\.txt) - [NC,L]
    RewriteRule ^.*$ index.php [NC,L]


    instead?
     
  5. BamaStangGuy

    BamaStangGuy Well-Known Member

    No luck, xenForo still tries to handle them.
     
  6. Slavik

    Slavik XenForo Moderator Staff Member

    There was a typo, in line 3,

    RewriteCond %{REQUEST_URI} "/store/
    should be

    RewriteCond %{REQUEST_URI} "/store/"
     
  7. BamaStangGuy

    BamaStangGuy Well-Known Member

    Still doesn't work :(
     
  8. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    I assume Wordpress has its own .htaccess file in /wordpress? Try setting an appropriate RewriteBase in there.

    RewriteBase /wordpress
     
  9. BamaStangGuy

    BamaStangGuy Well-Known Member

    Already have the base in there

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

    Slavik XenForo Moderator Staff Member

    ah maybe it should be

    RewriteCond %{REQUEST_FILENAME} !^/store/.*$
     
  11. BamaStangGuy

    BamaStangGuy Well-Known Member

    Still no luck
     
  12. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    I can take a look if you give me FTP access and some example URLs to test.
     
    Slavik likes this.
  13. Slavik

    Slavik XenForo Moderator Staff Member

    Probably easiest :D
     
  14. BamaStangGuy

    BamaStangGuy Well-Known Member

    Info sent
     
  15. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Fixed. This is your WP .htaccess file now:

    Code:
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /store
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^.*$ index.php [L]
    </IfModule>
    # END WordPress
    
    I removed the ending / from the RewriteBase, and I changed the last RewriteRule which had two problems.

    1) The URI match was just . which would only match one character, so I changed it to ^.*$ which will match any URI, just like XenForo's .htaccess file.

    2) I removed the beginning / from the target location so it's just index.php instead of /index.php. One is relative, the other is not.
     
    shawn and BamaStangGuy like this.
  16. BamaStangGuy

    BamaStangGuy Well-Known Member

    Thanks :)
     

Share This Page