Forum Moderators: phranque

Message Too Old, No Replies

moving wordpress blog .htaccess

         

thosecars82

12:53 am on Apr 7, 2010 (gmt 0)

10+ Year Member



Hello
I have a question related to a move of a wordpress blog.
I had it installed under www.domainx.com/blog
Now I want it under www.domainy.com/public_html/blog
I think the problem might happen because the .htaccess file under www.domainx.com/blog is no longer valid for being used under www.domainy.com/public_html/blog
The .htaccess file is

DirectoryIndex index.php

#The next lines enable SEO friendly permalinks in Wordpress 01/01/2010
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>

I have tried to change this file under www.domainy.com by adding /public_html in front of /blog:


DirectoryIndex index.php

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

Nonetheless, it still does not get the blog working.
Any idea?
Thanks

g1smd

5:45 am on Apr 7, 2010 (gmt 0)

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



Why do you want "public_html" to appear in your URL?

And if you do, you'd also need to redirect requests for OLD URLs to the new URL - to retain traffic following old links as well as tell searchengines to update their indexes.

No, instead you should retain the old URLs - and you can do that here too.

Where in the server FTP filesystem was the blog previously located?
Where is it located now?

thosecars82

8:42 am on Apr 7, 2010 (gmt 0)

10+ Year Member



It is not that I want public_html appearing in the URL. The problem is that the old domain called domainy.com forced to upload everything not to the server's root directory but to a folder under the root which was called /public_html That is why I thougt using a public_html folder under the new domain would make things easier.

Where in the server FTP filesystem was the blog previously located? /public_html/blog which was reachable with www.domainx.com/blog because the hosting provider's server I used was built so that all requests for www.domainx.com went to /public_html by default without any .htaccess file needed for this particular effect. These requests did not need to include public_html in the URL and still they were directed to /public_html folder by default like I said.

Where is it located now? /blog which should be reachable with www.domainy.com/blog

This hosting provider's server forces to use a folder called domainy.com. All requests for this domain go to /domainy.com by default.

g1smd

9:27 am on Apr 7, 2010 (gmt 0)

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



In that case, and as far as local paths go, change nothing in the .htaccess file when you re-use it.

In both cases the site is located in the /blog/ folder of the site root.

That has nothing to do with server root, and all to do with site root.

Do also check recent WebmasterWorld Apache forum threads where some alternative and much more efficient code for the Wordpress rewrite is presented.

thosecars82

11:55 am on Apr 7, 2010 (gmt 0)

10+ Year Member



Well, after doing what you told me (change nothing in the .htaccess file) I receive this error when browsing for www.domainy.com/blog/

"Error establishing a database connection"
in contrast to www.domainx.com/blog where I can see the blog.

I looked for the recent threads you mentioned but did not get to any conclusion yet.
The only thing I would like is avoiding having to mess up the original blog installation before knowing that it works fine in the new location.
Thanks

jdMorgan

12:35 pm on Apr 7, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It appears that may have to re-install WordPress anyway, since the error message you report indicates that WP is now looking for its database in the wrong location -- probably because it is a "hard-coded" path which is set during installation. Since WP accesses its database using filesystem references --as it should-- .htaccess can have no effect on WP database access, since it only affects HTTP requests.

This might be a good point to re-assess your choice of hosting, and consider whether you might be able to find a new host that is more compatible with the previous one.

Here's one of the threads that discusses improvements to the standard WP .htaccess code: [webmasterworld.com...]
I strongly suggest that you get your new WP install working properly before modifying any of its code, though.

Jim

thosecars82

12:52 pm on Apr 7, 2010 (gmt 0)

10+ Year Member



Hello
Are you suggesting to install a fresh wordpress at the new location/domain? How would I import all the posts, plugings,etc back into the new fresh wordpress at the new location/domain?

Thanks

jdMorgan

1:13 pm on Apr 7, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I suppose you'd copy the database files over, once you had the basic install working. You might also consider that the number of WP 'experts' you find will likely be higher in a WP-specific forum -- I don't use WP myself, so this advice is general -- and therefore only generally useful...

Jim