This is a discussion on .htaccess query within the Server / Technical Administration Tips and Queries forums, part of the Webmaster Help category; Hi guys, i wish to add to the current .htaccess file that resides in my blog root so that if ...
| |||||||
| Register | Forum Rules | FAQ | Donate | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||||
| Hi guys, i wish to add to the current .htaccess file that resides in my blog root so that if a user types in http://domain.com they're automatically redirected to http://www.domain.com. I have opened up the current .htaccess file and I found the following: # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase /blog/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /blog/index.php [L] </IfModule> # END WordPress To enforce the www i added the following to the .htaccess file: Options +FollowSymLinks RewriteEngine On RewriteCond %{HTTP_Host} ^cormacmoylan.com/blog [NC] RewriteRule ^(.*)$ http://www.cormacmoylan.com/blog/$1 [L,R=301] But it doesn't enforce the rule. Does anyone know where i'm going wrong? |
| ||||
| I dont think you need it in the blog but rather in the root folder of the domain although I find htaccess tricky at the best of times. Try: RewriteCond %{HTTP_HOST} !^www\.yourdomain\.com$ [NC] RewriteRule .* http://www.yourdomain.com/ [L,R=301] |
| |||||
| Where did you put the second block? # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On Options +FollowSymLinks RewriteCond %{HTTP_Host} ^cormacmoylan.com/blog [NC] RewriteRule ^(.*)$ http://www.cormacmoylan.com/blog/$1 [L,R=301] RewriteBase /blog/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /blog/index.php [L] </IfModule> # END WordPress Similar works for me except it appears WP takes it upon itself to rollback the file every so often
__________________ Search Engine Optimisation - Red Cardinal Internet Marketing Internet Consultant Ireland | Search Engine Optimisation Services Catering Company Dublin - My sister's handmade canape company! |
| |||||
| If you want to rewrite the entire domain then it should be in the root
__________________ Hosting & Domains|Plesk Vps Hosting|Geek / Cool Stuff|Films.ie|Cool Sites|Monetisation Tips|Movie Chat Energise your forum! Click here for info |
| |||||
| RewriteEngine On RewriteCond %{HTTP_HOST} !^(www\.|$) [NC] RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] Then in your case, /blog |