views:

100

answers:

3

For example I have a live WP site http://wpsite.com

I wanted to make a live mirror copy of http://wpsite.com at http://wpsite.com/test/

so i copied all data of public_html/ folder to public_html/test/

then i checked http://wpsite.com/test/ but everything is going to http://wpsite.com/

is there any .htaccess problem?

This is .htaccess at public_html/

# BEGIN WPSuperCache
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
AddDefaultCharset UTF-8
RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{QUERY_STRING} !.*=.*
RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress|wp-postpass_).*$
RewriteCond %{HTTP_USER_AGENT} !^.*(2.0\ MMP|240x320|400X240|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|Googlebot-Mobile|hiptop|IEMobile|KYOCERA/WX310K|LG/U990|MIDP-2.|MMEF20|MOT-V|NetFront|Newt|Nintendo\ Wii|Nitro|Nokia|Opera\ Mini|Palm|PlayStation\ Portable|portalmmm|Proxinet|ProxiNet|SHARP-TQ-GX10|SHG-i900|Small|SonyEricsson|Symbian\ OS|SymbianOS|TS21i-10|UP.Browser|UP.Link|webOS|Windows\ CE|WinWAP|YahooSeeker/M1A1-R2D2|iPhone|iPod|Android|BlackBerry9530|LG-TU915\ Obigo|LGE\ VX|webOS|Nokia5800).*
RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html.gz -f
RewriteRule ^(.*) /wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html.gz [L]

RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{QUERY_STRING} !.*=.*
RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress|wp-postpass_).*$
RewriteCond %{HTTP_USER_AGENT} !^.*(2.0\ MMP|240x320|400X240|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|Googlebot-Mobile|hiptop|IEMobile|KYOCERA/WX310K|LG/U990|MIDP-2.|MMEF20|MOT-V|NetFront|Newt|Nintendo\ Wii|Nitro|Nokia|Opera\ Mini|Palm|PlayStation\ Portable|portalmmm|Proxinet|ProxiNet|SHARP-TQ-GX10|SHG-i900|Small|SonyEricsson|Symbian\ OS|SymbianOS|TS21i-10|UP.Browser|UP.Link|webOS|Windows\ CE|WinWAP|YahooSeeker/M1A1-R2D2|iPhone|iPod|Android|BlackBerry9530|LG-TU915\ Obigo|LGE\ VX|webOS|Nokia5800).*
RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html -f
RewriteRule ^(.*) /wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html [L]
</IfModule>
# END WPSuperCache
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

and This is the .htaccess at public_html/test (both are same)

# BEGIN WPSuperCache
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
AddDefaultCharset UTF-8
RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{QUERY_STRING} !.*=.*
RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress|wp-postpass_).*$
RewriteCond %{HTTP_USER_AGENT} !^.*(2.0\ MMP|240x320|400X240|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|Googlebot-Mobile|hiptop|IEMobile|KYOCERA/WX310K|LG/U990|MIDP-2.|MMEF20|MOT-V|NetFront|Newt|Nintendo\ Wii|Nitro|Nokia|Opera\ Mini|Palm|PlayStation\ Portable|portalmmm|Proxinet|ProxiNet|SHARP-TQ-GX10|SHG-i900|Small|SonyEricsson|Symbian\ OS|SymbianOS|TS21i-10|UP.Browser|UP.Link|webOS|Windows\ CE|WinWAP|YahooSeeker/M1A1-R2D2|iPhone|iPod|Android|BlackBerry9530|LG-TU915\ Obigo|LGE\ VX|webOS|Nokia5800).*
RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html.gz -f
RewriteRule ^(.*) /wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html.gz [L]

RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{QUERY_STRING} !.*=.*
RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress|wp-postpass_).*$
RewriteCond %{HTTP_USER_AGENT} !^.*(2.0\ MMP|240x320|400X240|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|Googlebot-Mobile|hiptop|IEMobile|KYOCERA/WX310K|LG/U990|MIDP-2.|MMEF20|MOT-V|NetFront|Newt|Nintendo\ Wii|Nitro|Nokia|Opera\ Mini|Palm|PlayStation\ Portable|portalmmm|Proxinet|ProxiNet|SHARP-TQ-GX10|SHG-i900|Small|SonyEricsson|Symbian\ OS|SymbianOS|TS21i-10|UP.Browser|UP.Link|webOS|Windows\ CE|WinWAP|YahooSeeker/M1A1-R2D2|iPhone|iPod|Android|BlackBerry9530|LG-TU915\ Obigo|LGE\ VX|webOS|Nokia5800).*
RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html -f
RewriteRule ^(.*) /wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html [L]
</IfModule>
# END WPSuperCache
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress
A: 

no, you have to modify your Test wordpress blog address in the Settings/general panel to your Test folder.

pixeline
@pixeline - but the problem is when i open http://wpsite.com/test_site/wp-login.php it's not opening login page.
metal-gear-solid
you're being locked out because you need to fix it in the database. Look for the wp_options table. Inside, there is an option blog_url (if i remember correctly) which stores the url.
pixeline
@pixeline but i haven't specified database for wpsite.com/test_site/
metal-gear-solid
then you are using your main database, so modify that one or create a copy, and modify your test/wp-config.php to connect to the copied database instead.
pixeline
+3  A: 

There are two settings in the wp_options table. These determine where your blog files are, and where the main index is:

  • siteurl
  • home

You can edit these in the general settings, but you can override these in your wp-config.php file with WP_HOME and WP_SITEURL. I usually just add something like this little snippet so my development links work just fine as well:

$server = $_SERVER['SERVER_NAME'];
define('WP_HOME',"http://{$server}");
define('WP_SITEURL',"http://{$server}");

Note that these override any values you may have set in the general settings config screen of wordpress. Check this link out for the full details.

Typeoneerror
but i haven't attached or created any database for http://wpsite.com/test/ even url showing all data except blog posts.
metal-gear-solid
I have 2 wp-confing.php files one inside/public_html/ and another inside public_html/test/
metal-gear-solid
it'd still use the same database as your production site until you change the connection parameters in wp-config.
Typeoneerror
I want to make a mirror copy of wpsite.com database for wpsite.com/test/ because i will something on wpsite.com/test/
metal-gear-solid
just copy your database and change test/wp-config.php to reflect the new one.
Typeoneerror
@Typeoneerror - all database related info in `test/wp-config.ph`p is blank but `wpsite.com/test` still showing all data except blog posts.
metal-gear-solid
Let's see. You probably need to update the rewrite rules as well in /test to use /test as the base instead of /. Check out the post below as well.
Typeoneerror
A: 

Edit: I missed the part where you said that was your public_html/ (and not public_html/test/) .htaccess, so this may actually not apply...

I imagine there's a WordPress setting that should control this, as WordPress automatically generates the .htaccess file for you when specifying your permalink structure, but I'm not sure.

In any case, in addition to the other considerations mentioned, the reason why going to example.com/test/ shows the WordPress site at example.com is because your .htaccess file points to /index.php, which is interpreted as example.com/index.php.

To fix it, update your RewriteRule to be either

RewriteRule . /test/index.php [L]

or

RewriteRule . index.php [L]

Again, I'd check to see if there's functionality to define this inside of WordPress (probably resulting in the first option), as if you change your permalink settings I imagine WordPress will overwrite this section.

A more detailed explanation of why mod_rewrite views /index.php as being different from index.php in this case can be found in the final edit to my answer to this question.

Tim Stone
@Tim - I have 2 .htaccess file with same data one at `http://wpsite.com/` and another at `http://wpsite.com/test/` in which file i should change?
metal-gear-solid
@Tim - I changed `RewriteRule . /index.php [L]` to `RewriteRule . /test/index.php [L]` for `test/.htacces` but no change.
metal-gear-solid
@metal-gear-solid - Hmm, it works on my test server (in a very simplified setting). Did you make sure that WPSuperCache didn't create a cache of the main site's index for the test site's index from before you changed the rules, that it's now showing you after you changed the rules? (I have no idea what it caches and doesn't cache)
Tim Stone
@Tim 0 i removed WP supercache part from test/.htacces file. this is .htaccess file for `wpsite.com/test/` `# BEGIN WordPress<IfModule mod_rewrite.c>RewriteEngine OnRewriteBase /test/RewriteRule ^index\.php$ - [L]RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule . /test/index.php [L]</IfModule># END WordPress`but it's now working
metal-gear-solid
@metal-gear-solid - The supercache bit from the `public_html/.htaccess` will also be used for the `public_html/test/` site because it's a subdirectory. You could exclude `/test/` by adding `RewriteCond %{REQUEST_URI} !^/test` to the condition list. That could easily not be the problem though, I was just trying to figure out why your environment might be behaving differently than mine.
Tim Stone
@Tim - I added `RewriteCond %{REQUEST_URI} !^/test` in public_html/.htaccess just above the `RewriteCond %{QUERY_STRING} !.*=.*` but no effect.
metal-gear-solid