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

www apache wordpress

Discussion in 'Web Design' started by Mutikasa, Jan 16, 2013.

  1. Mutikasa

    Mutikasa Power Member

    Joined:
    May 23, 2011
    Messages:
    581
    Likes Received:
    207
    So, I populated wordpress with posts and then made apache Vhost to point domain to wordpress folder. First, i needed to change site URL from General Options in database. I put like this http://www.example.com with www part. But when i enter the link in address bar it redirects me to the default root folder (/var/www/, wordpress is in /var/www/wordpress/) and www part disappears from url. I don't know why wordpress redirects me to without www part and apache activates default Vhost. This is the .htaccess of wordpress
    Code:
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /wordpress/
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /wordpress/index.php [L]
    </IfModule>
    
    # END WordPress
    I did manage to find solution which is creating .htaccess in the root folder which redirect to the url WITH www part. This is it:
    Code:
    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteRule ^(.*)$ http://www.%{HTTP_HOST}$1 [R=301,L]
    But i still want to know why and how wordpress does that and how to fix it inside wordpress.
    Thanks
     
  2. The Web Designer

    The Web Designer Regular Member

    Joined:
    Jul 22, 2012
    Messages:
    350
    Likes Received:
    320
    Location:
    Borneo
    Hi.

    While some of the members of BHW are experienced with WordPress, I think it would be much better
    if you get your answers from the official site, i.e http://codex.wordpress.org . You can find
    more answers there.
     
  3. carlikito

    carlikito Regular Member

    Joined:
    Dec 28, 2009
    Messages:
    350
    Likes Received:
    214
    Check your permalinks structure. Also without knowing more about your configuration, I think the www part is causing you problems. try removing it from the url and see what happens.
     
  4. Mutikasa

    Mutikasa Power Member

    Joined:
    May 23, 2011
    Messages:
    581
    Likes Received:
    207
    Well, I think I solved it. I set the permalinks to default, then deleted wordpress .htaccess, then set permalinks again so the new .htaccess was created. For now it's working fine.
    The new one looks like this:
    Code:
    # 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
    
    the catch was in the RewriteBase and last RewriteRule "wordpress" path.
     
    Last edited: Jan 17, 2013