Giving WordPress Its Own Directory

Discussion in 'PHP' started by nikaway, Jun 9, 2013.

  1. #1
    I tried but unfortunately don't works... I try [NC, L] intead of [L] but I get Error Internal Server (500).

    I have a Wordpress in directory /site, but I want to use www.mydomain.com do access it. Then I do it:

    http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory

    It works, i Get good installation in folder "/site" and I get access with www.mydomain.com instead www.mydomain.com / site. But... When I access my html websites in www.mydomain.com/pagehtml/otherpagehtml it don't works... I get a error 404 not found entry in blog...

    Ie installing Wordpress are thinking that my html pages links from other directories I have are links to the posts wordpress site. I think this is all because of some rule in. Htaccess ...
     
    nikaway, Jun 9, 2013 IP
  2. aidanriley629

    aidanriley629 Banned

    Messages:
    429
    Likes Received:
    23
    Best Answers:
    3
    Trophy Points:
    175
    #2
    You could just put a redirect on www.mydomain.com to go to your Wordpress site, but all the links from there will not be coming from www.mydomain.com anymore. If that's something you'd like, it's easy. In fact, here:
    <html>
    <?php
    header('Location: http://www.YourWordpressSite.com/');
    exit;
    ?>
    </html>
    Code (markup):
     
    aidanriley629, Jun 9, 2013 IP
  3. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #3
    Post your htaccess if possible. Almost every time I've had problems like this it was htaccess related.
     
    jestep, Jun 10, 2013 IP
  4. Avener

    Avener Well-Known Member

    Messages:
    250
    Likes Received:
    24
    Best Answers:
    1
    Trophy Points:
    135
    #4
    That's pretty messy way of doing it and the "<html>" tags are not needed.

    The .htaccess method will do the trick perfectly.
    RewriteCond %{HTTP_HOST} ^(www.)?domain.com$
    RewriteCond %{REQUEST_URI} !^/domain/
    RewriteCond /domain/%{REQUEST_URI} -d
    RewriteCond %{REQUEST_URI} !(.*)/$
    RewriteRule ^(.*)$ /domain/$1/
     
    RewriteCond %{HTTP_HOST} ^(www.)?domain.com$
    RewriteCond %{REQUEST_URI} !^/domain/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /domain/$1
     
    RewriteCond %{HTTP_HOST} ^(www.)?domain.com$
    RewriteRule ^(/)?$ /domain/index.php [L]
    Code (markup):
    Source: http://stackoverflow.com/questions/5986473/htaccess-change-domain-root-to-sub-directory
     
    Avener, Jun 10, 2013 IP
  5. nikaway

    nikaway Active Member

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    56
    #5
    Hello everybody! I want to do a good method for SEO redirections, I think:
    <html>
    <?php
    header('Location: http://www.YourWordpressSite.com/');
    exit;
    ?>
    </html>
    Code (markup):
    Is not very cool despite being simple...

    Well.. Yes.. I think is any rule in my .htaccess file.. That is all my code from .htaccess from my public_html folder:

    Options -Indexes
    #Não autoriza listagem de pastas
     
    <Files ~ "^\.(htaccess|htpasswd)$">
      deny from all
    </Files>
    #bloquear arquivos especídifos contra acesso pelas URLs
     
     
    <FilesMatch "\.(txt|sql|ini)$">
    Deny from all
    </FilesMatch>
    #bloquear acessar pela URL txt, sql e ini
     
     
    <Files wp-config.php>
    order allow,deny
    deny from all
    </Files>
    #Protege o wp-config de acessos
     
     
     
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^mydomain.com
    RewriteRule ^ http://www.mydomain.com%{REQUEST_URI} [L,R=301]
    # Redirecionar URL sem www para www
     
     
     
     
     
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}\.html -f
    RewriteRule ^(.*)$ $1.html
    # Replace html with your file extension, eg: php, htm, asp
    #Oculta extensões HTML de páginas
     
     
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}\.htm -f
    RewriteRule ^(.*)$ $1.htm
    # Replace html with your file extension, eg: php, htm, asp
    #Oculta extensões HTM de páginas
     
     
     
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}\.php -f
    RewriteRule ^(.*)$ $1.php
    # Replace php with your file extension, eg: php, htm, asp
    #Oculta extensões PHP de páginas
     
     
    AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/javascript text/css application/x-javascript
    BrowserMatch ^Mozilla/4 gzip-only-text/html
    BrowserMatch ^Mozilla/4.0[678] no-gzip
    BrowserMatch bMSIE !no-gzip !gzip-only-text/html
    #Aliviar peso de página para visitantes
     
     
    ErrorDocument 400 http://www.mydomain.com/errors/400.html
    ErrorDocument 401 http://www.mydomain.com/errors/401.html
    ErrorDocument 403 http://www.mydomain.com/errors/403.html
    ErrorDocument 404 http://www.mydomain.com/errors/404.html
    ErrorDocument 500 http://www.mydomain.com/errors/500.html
    #páginas de erro personalizadas
     
     
    redirect 301 /hospede-aqui.html http://www.mydomain.com/blog/hospede-todo-tipo-de-arquivos-gratis-no-dropbox/
    # redireciona URL antiga para URL nova
     
     
    # Protege contra spam bots nos comentários
    # dicas otimas mastermindblogger.com/2011/5-simple-tricks-to-prevent-wordpress-spam-comments
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_METHOD} POST
    RewriteCond %{REQUEST_URI} .wp-comments-post\.php*
    RewriteCond %{HTTP_REFERER} !.mydomain.com.* [OR]
    RewriteCond %{HTTP_USER_AGENT} ^$
    RewriteRule (.*) ^http://%{REMOTE_ADDR}/$ [R=301,L]
    </IfModule>
     
     
     
     
    RewriteEngine On
    RewriteBase /
    RewriteRule ^wp-admin/includes/ - [F,L]
    RewriteRule !^wp-includes/ - [S=3]
    RewriteRule ^wp-includes/[^/]+\.php$ - [F,L]
    RewriteRule ^wp-includes/js/tinymce/langs/.+\.php - [F,L]
    RewriteRule ^wp-includes/theme-compat/ - [F,L]
    # Bloquear contra acessos na área de scripts do wordpress no wp-include
     
    # 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>
    
    Code (markup):
    And ... Jackderips, that code you pasted is for to insert in .htaccess from public_html or .htaccess from /site folder??!

    Should I put "RewriteRule ^(.*)$ /domain/site/$1/" or RewriteRule ^(.*)$ /domain/$1/ ??
     
    nikaway, Jun 10, 2013 IP
  6. nikaway

    nikaway Active Member

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    56
    #6
    Hey buddies...

    I discovered a strange symptom... Only my subdirectories with protection HTTP (.htaccess/.htpasswd) are taken as entry which not exists in my WP from my domain.

    But, subdirectorios without that protection are accessible OK.

    See what have in .htaccess in www.site.com/directory/subdirectoryprotected:

    AuthType Basic
    AuthName "PRIVATE AREA"
    AuthUserFile "/home/user6/public_html/htpasswds/.htpasswd"
    require user user2013
     
    ErrorDocument 400 http://www.site.com/acesso-negado.html
    ErrorDocument 401 http://www.site.com/acesso-negado.html
    ErrorDocument 403 http://www.site.com/acesso-negado.html
    ErrorDocument 404 http://www.site.com/acesso-negado.html
    ErrorDocument 500 http://www.site.com/acesso-negado.html
    #pages personalized
    Code (markup):
     
    nikaway, Jun 10, 2013 IP
  7. Avener

    Avener Well-Known Member

    Messages:
    250
    Likes Received:
    24
    Best Answers:
    1
    Trophy Points:
    135
    #7
    That is what you need, isn't it?
    The .htaccess code I posted should work just fine for you.
     
    Avener, Jun 11, 2013 IP
  8. nikaway

    nikaway Active Member

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    56
    #8
    Hello, don't works... All my directories protected with .htaccess are taken as Posts don't exists in my Wordpress installation.
     
    nikaway, Jun 11, 2013 IP