Forum Moderators: mack
I have read that 301 redirect can fix this, but when I look at CPanel I only got this option
ADD REDIRECT:
[mysite.com...] >>> [mysite.com...]
PERMANENT
and it ads string on the bottom of htacess file like:
RedirectMatch permanent ^/$ [mysite.com...]
Will this solved my problems? Or are there any other more strings/script to be made when I want all the pages to be resolved as www.mysite.com?
RewriteCond %{HTTP_HOST}!^www\.mysite\.com [NC]
RewriteRule ^(.*)$ [mysite.com...] [R=301,L]
If you cannot see your .htaccess in your FTP client - make sure you are viewing hidden files. Also, make sure to edit your .htaccess using something like TextPad, UltraEdit etc.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME}!-f
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Will this have a conflict if I put the strings you suggested? Thanks a lot.
==================================================
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME}!-f
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
RewriteCond %{HTTP_HOST}!^www\.mysite\.com [NC]
RewriteRule ^(.*)$ [mysite.com...] [R=301,L]
==================================================
Just to make sure before I implement it. Thanks a lot for your help.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
#
# Redirect to canonical domain
RewriteCond %{HTTP_HOST} !^www\.mysite\.com [NC]
RewriteRule (.*) http://www.mysite.com/$1 [R=301,L]
#
# BEGIN WordPress
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
</IfModule>
What if its is a subdirectory such as
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /subdirectory1/
RewriteCond %{REQUEST_FILENAME}!-f
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule . /subdirectory1/index.php [L]
</IfModule>
# END WordPress
==Would it be like:====
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /subdirectory1/
#
# Redirect to canonical domain
RewriteCond %{HTTP_HOST}!^www\.mysite\.com [NC]
RewriteRule (.*) [mysite.com...] [R=301,L]
#
# BEGIN WordPress
RewriteCond %{REQUEST_FILENAME}!-f
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule . /subdirectory1/index.php[L]
# END WordPress
</IfModule>