Maxim Shoustin
Maxim Shoustin

Reputation: 77904

How to change root url in wordpress for existing blog

I did mistake and didnt change my root URL when started work with WordPress, for now I have my blog with about 30 pages and I need change root URL.

when I run my main page aka index.php I see http://www.myblog.co.il/wordpress therefore all generated permalinks look like: http://www.myblog.co.il/wordpress/?page_id=158 ... .

The main quiestion is: How to change:

http://www.myblog.co.il/wordpress to 'http://www.myblog.co.il/' in order to change automatically all permalinks? a.e. http://www.myblog.co.il/?page_id=158 ...

I saw enough solutions how to do that from start but not when blog is ready.

Please, help me to find proper solution.

Thanks,

Upvotes: 0

Views: 2736

Answers (3)

tobbr
tobbr

Reputation: 2186

Well first of you'll have to configure a virtual host in Apache to match the domain to your htdocs\wordpress folder and not just to \htdocs. You can read more on vhosts in apache here.

Since Wordpress saves all URLS in their absolute form to the database, you'll have to manually fix this by replaceing the URLS in the database. Assuming you're running MySQL and the current URL to your blog is http://www.myblog.co.il/wordpress, you can use these queries:

UPDATE wp_posts SET post_content = REPLACE(post_content, 'http://www.myblog.co.il/wordpress', 'http://www.myblog.co.il');
UPDATE wp_posts SET guid = REPLACE(guid, 'http://www.myblog.co.il/wordpress', 'http://www.myblog.co.il');
UPDATE wp_options SET option_value = 'http://www.myblog.co.il' WHERE option_name = 'home' OR option_name = 'siteurl';

this does not only fix hardcoded links but it also fixes custom links inside the content of your pages and posts.

Upvotes: 1

Michael Marr
Michael Marr

Reputation: 2099

Assuming nothing else is in root htdocs directory, i.e. if you go to http://www.myblog.co.il/ nothing should show up, update your URL via the admin backend (or via MySQL wp_options table), and move everything inside of the wordpress directory back into the htdocs directory.

Upvotes: 0

RRikesh
RRikesh

Reputation: 14381

You tried changing siteurl and home in your options table?

I'm not sure of understanding what you mean, but the page on Moving WordPress might help you.

Upvotes: 1

Related Questions