Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

HTACCESS Problem WordPress

Hello, I have a problem with htaccess well I need these fixs.

1) I have wordpress multisite and wordpress automatically create my posts like website.com/blog/post-name well and if I type [[LINK href="http://www.milanchymcak.com/blog/"]]/BLOG/[[/LINK]] there is a blank page and I tried also created page for that url and it doesnt work. So all I want to do is to redirect [[LINK href="http://www.milanchymcak.com/blog/"]]/BLOG/[[/LINK]] to [[LINK href="http://www.milanchymcak.com/blog"]]/BLOG[[/LINK]]

2) I also want to redirect non-www to www but if I type website.com/postname it will redirect to www.website.com but not to www.website.com/postname ..so what I need to do is redirect this [[LINK href="http://milanchymcak.com/reviews/honest-google-sniper-2-0-review"]]non-www[[/LINK]] to this [[LINK href="http://www.milanchymcak.com/reviews/honest-google-sniper-2-0-review"]]with-www[[/LINK]]

Here is my current htaccess

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

Answers (2)

2013-09-25

Navjot Singh answers:

Change it to

# 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
RewriteEngine On
RewriteCond %{HTTP_HOST} ^mydomain.com$
RewriteRule (.*) http://www.mydomain.com/$1 [R=301,L]


Navjot Singh comments:

Just read that its multisite. Don't use the above code. Just add the following lines to your .htaccess at the bottom.


RewriteEngine On
RewriteCond %{HTTP_HOST} ^mydomain.com$
RewriteRule (.*) http://www.mydomain.com/$1 [R=301,L]


Navjot Singh comments:

And remove these lines

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>


Chymmi comments:

Nice :) you fixed /blog/ issue ..but now how I can fix second problem ..I want to redirect all these urls
website.com/postname -> www.website.com/postname

now if I type website.com/postname it will only redirect it to www.website.com


Navjot Singh comments:

Did you add these lines?

RewriteEngine On
RewriteCond %{HTTP_HOST} ^mydomain.com$
RewriteRule (.*) http://www.mydomain.com/$1 [R=301,L]

?


Navjot Singh comments:

You can also use the tips [[LINK href="http://wordpress.stackexchange.com/a/77163"]]mentioned here[[/LINK]] to change your blog to www version.

2013-09-25

Rowela Alzona answers:

Open your .htaccess to a notepad or any other word editor and try this one:


<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
RewriteRule ^(.*).html /$1
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>


I just fix had the same problem today and it is now fixed.