Boris Zegarac
Boris Zegarac

Reputation: 531

htaccess not working OK

I have below code inside my .htaccess which is placed inside my wordpress blog located under subdomain. Now I moved my blog under subfolder and I placed 301 redirects from subdomain but when I visit pages at blog.domain.com I get 500 internal server error instead of getting 301 redirects to http://domain.com/blog/

# Use PHP5 as default
AddHandler application/x-httpd-php5 .php


RewriteCond %{HTTP_HOST} ^blog\.stream-tek\.com
RewriteRule ^(.*)$ http://www.stream-tek.com/blog/$1 [R=301]


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

# END WordPress

Now when I remove code between:

# BEGIN WordPress
# END WordPress

I get 301 redirects from subdomain pages, but when I return it back its not working. I need that part of code since wordpress clean urls wont work without that.

What is the problem with above htaccess file since I am not expert with that.

Thanks for help.

Upvotes: 1

Views: 71

Answers (1)

anubhava
anubhava

Reputation: 784878

Problem is the WP stuff take full control even before your redirect gets a chance to kick in.

Change the order of rules.

# Use PHP5 as default
AddHandler application/x-httpd-php5 .php
RewriteEngine On
RewriteBase /blog/
<IfModule mod_rewrite.c>

RewriteCond %{HTTP_HOST} ^blog\.stream-tek\.com$ [NC]
RewriteRule ^ http://www.stream-tek.com/blog%{REQUEST_URI} [R=301,L]

# BEGIN WordPress
RewriteRule ^index\.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]

</IfModule>
# END WordPress

Upvotes: 1

Related Questions