Forum Moderators: phranque

Message Too Old, No Replies

Changing URL .htaccess problem

         

sanufdutta16

7:14 am on May 26, 2014 (gmt 0)

10+ Year Member



Hello,
I have a site with domain name with .ORG extension, and now I'm willing to migrate into .NET ! But, I don't know .htaccess file script!

And another issue is that permalink structure is .org/?p=234, this kind of...and I have around 30 articles so far. I changed earlier this on Wordpress, but found 404 error with clean permalink structure...Because unable to edit the .htaccess file.

TWO Issues in a same website.

1. Migration - .ORG to .NET
2. Permalink Change - to clean ones.


How to change it, and please suggest me some Step-by-step tutorial.

Thanks!

not2easy

8:33 am on May 26, 2014 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Hello sanufdutta16, welcome to Webmaster World. Your question would probably get better assistance in the WordPress Forum: [webmasterworld.com...] where people are more familiar with changes and moving WordPress installs to new domains. The clean URL settings are in your permalink settings in the Settings file which is also where you would set your site's URL. Your question is related to htaccess and Apache, but because WordPress deals with things a little differently a good answer to htaccess questions for another kind of site won't usually work on a WP site.

To move a domain the config file needs to be edited, you should keep your site active on your current domain, while you install a new WP (empty) install on the new domain, and enter the new settings in the config file. If your new domain has software installers, that makes it simple because configurations are set automatically during the install. The software installers I've seen usually do not install the current version so you will need to update it. Then you copy your .sql database from your current domain and upload it to your new database using the new settings. Many hosting sites will even do this for you, or help you if you aren't sure how to do each step. The important thing is to keep track of your logins and passwords for both sites and for both databases. Most plugins allow you to copy (export) current settings and import them to the new site. You will need to download a copy of your themes and images from the old site and upload them to the new one.

A completely different way to move a WP site is to use Control Panel to gzip one entire install and upload it to the new domain. You can do it that way and have a complete copy - BUT you will need to take a copy of your current config file and change it to match your new settings where needed and you still need to copy over the .sql file. It is common to lock yourself out at this step, but only until all the parts fit together with the right settings. The Wordpress.org site has step by step instructions that might explain it all more clearly than I have.

sanufdutta16

10:57 am on May 26, 2014 (gmt 0)

10+ Year Member



Well, I find the process quite messy and I need to put lot of effort in it. Though I found WP Installer for redirects, and just hoping it will redirect the URLs. But, still unsure about domain migration.

phranque

11:05 pm on May 26, 2014 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



welcome to WebmasterWorld, sanufdutta16!


you have 2 distinct and unrelated issues.
as not2easy suggested, you should post a separate thread in the Wordpress forum to get the best solution for your permalink change.


your migration from example.org to example.net should be handled by the hostname canonicalization redirect(s) in your .htaccess file.
what do you have so far?
please post the relevant mod-rewrite directives from your .htaccess file


IMPORTANT: Please Use Example.com (or .net or .org) For Domain Names in Posts:
http://www.webmasterworld.com/apache/4452736.htm [webmasterworld.com]

lucy24

1:44 am on May 27, 2014 (gmt 0)

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



Question I don't find the answer to:

Will the old .org and the new .net live in the same physical place? That means either:
-- the same server, if it's your own server or VPS (something tells me this is not your situation)
or
-- on shared hosting, one of the two is the primary while the other is an addon domain (if your host uses the "userspace" structure, this doesn't count as "same place")

The crucial question is whether requests for the old and new domain will pass through the same htaccess file-- or, more exactly, the same set of mod_rewrite directives. This is determined by where the two sites are physically located, independent of domain name.

unable to edit the .htaccess file.

Do you mean that you're not allowed to edit it, or that you don't know how (yet)?

sanufdutta16

3:50 am on May 29, 2014 (gmt 0)

10+ Year Member



Well, I don't know anything about .htaccess, the reason why I'm asking again n again.

Thankfully a guy suggested me this -

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} example\.hosting\.org [NC]
RewriteRule (.*) http://example.net/$1 [R=301,L]
</IfModule>



DONE...! But, I have 13-14 Articles available in this site, what will happen with their permalinks, they'll auto change after uploading this file or not ? That's my concern.

[edited by: phranque at 4:43 am (utc) on May 29, 2014]
[edit reason] exemplified hostnames [/edit]

lucy24

4:35 am on May 29, 2014 (gmt 0)

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



If you're using WordPress, you can't just shove in a new RewriteRule any old where. You have to integrate it with your existing RewriteRules and make sure everything is in the right order. The only exception is if you're discontinuing the old domain, so its htaccess will not contain any RewriteRules except the ones redirecting to the new domain-- and then only if the two domains are on different paths.

The <IfModule envelope is unnecessary. If you didn't have mod_rewrite you wouldn't be able to use WordPress (or any other major cms).

not2easy

4:41 am on May 29, 2014 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Is your new .net domain hosted at the same host as the old .org domain?

phranque

4:52 am on May 29, 2014 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Thankfully a guy suggested me this -

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} example\.hosting\.org [NC]
RewriteRule (.*) http://example.net/$1 [R=301,L]
</IfModule>


i would suggest this instead:

RewriteCond %{HTTP_HOST} !^(example\.net)?$ [NC]
RewriteRule (.*) http://example.net/$1 [R=301,L]


(assuming you already have 'RewriteEngine on' elsewhere)

this means, redirect to example.net if the requested hostname isn't exactly example.net (or nothing for HTTP/1.0 user agents which don't send a Host: header with the HTTP Request).

this ruleset would redirect requests for www.example.net to example.net while your RewriteCond would prevent that.

as lucy24 implied the hostname canonicalization redirect must go before the internal rewrites required for WP.