www apache wordpress

Mutikasa

Power Member
Joined
May 23, 2011
Messages
589
Reaction score
216
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
 
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.
 
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.
 
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:
Back
Top