Forum Moderators: phranque

Message Too Old, No Replies

move blog folder to subdomain

htaccess rule

         

rehmat

4:19 pm on Dec 9, 2011 (gmt 0)

10+ Year Member



Hi All,

i have setup wordpress initially as http://www.example.com/blog , now moved it to a sub-domain in apache like [blog.example.com,...] and changed the URL values in WP-Admin Panel.
I setup the .htaccess file in main domain, and added this rule
" RedirectMatch 301 ^/blog/(.*)$ [blog.example.com...] "
to point old blog URL to the new URL.
Now the the problem is, when i search my blog in google, and then click on the blog articles links, it redirect me to the new blog site, fine till now. but the url in the browser, contains multiple articles names, like this :
" [blog.example.com...] "
i want to remove the 2nd occurrence of the ArticleName in the URL.

Thanks in advance.

phranque

1:27 am on Dec 10, 2011 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



welcome to WebmasterWorld, rehmat!

i would guess you are mixing mod_rewrite and mod_alias directives in your .htaccess and possibly your server config file.
do you have any RewriteRule directives in your .htaccess?
if so, you should do all your redirects with mod_rewrite and do all your redirects before your rewrites or you will expose your internal URIs.

lucy24

1:52 am on Dec 10, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You have probably noticed by now that "blog.example.com" is not a protected address ;) It will work if you leave off the leading http:// but when quoting your exact rules you will have to resort to trickery.

The "2nd occurrence" you refer to is in the query string. If you change to mod_rewrite you will need to add a condition; by default, mod_rewrite simply does not "see" the query string. Do a Forums search for "QUERY_STRING" + "boilerplate" for more information than you will ever need.

rehmat

4:46 am on Dec 12, 2011 (gmt 0)

10+ Year Member



Thanks Phranque & Lucy24,for your suggestions,

the problem is solved, as i removed rules from .htaccess and put one redirect line in httpd.conf, as below:
# vi /etc/httpd/conf/httpd.conf

" Redirect permanent /blog [blog.example.com...] "

it was not working prior, may be due to conflicting fules, but now i sorted out the .htaccess rules and httpd.conf directives. Its perfectly fine now.

Thanks once again.