Quantcast
Channel: WordPress.org Forums » All Posts
Viewing all articles
Browse latest Browse all 134817

jumbo1 on "WordPress htaccess overrides rewrite rule"

$
0
0

Hi All,

I'm having a problem with rewriting urls with wordpress.

I have my blog in a subdomain like: blog.domain.com
Whenever someone types domain.com/blog I want them to be redirected to blog.domain.com

I'm using the following in htaccess:
RewriteCond %{HTTP_HOST} ^domain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.domain.com$
RewriteRule ^blog(.*)$ http://blog.domain.com [R=301,L]

This code works if wordpress' default htaccess is removed, which is:
# 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>

If I keep this code however, url domain.com/blog doesn't get redirected, and I get a 404 page error.
But of course, removing the wordpress default htaccess breaks wordpress down.

Anyone has any solution to make it work?


Viewing all articles
Browse latest Browse all 134817

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>