Here I want to ask two question.
I upload my magento website from localhost to main server. My website link is this
http://bigtechideas.com/dope
Problem:1 - When I open url http://bigtechideas.com/dope/admin it returns this http://bigtechideas.com/dopeindex.php/admin
Why it add index.php in url ?
Problem:2 - When I open http://bigtechideas.com/dope it returns me https://bigtechideas.com/dope
Why it add HTTPS in url?
This is all configured through the Magento backend. You have to set an URL for unecrypted and encrypted pages (http & https) in the settings. If you move a Magento installation from one server to anther you have to edit those URLs.
You could also use the following SQL snippets to directly modify the settings in the database. (I can't guarantee that it is complete, but it should)
-- move Magento to another server
SET #shop_domain = 'YOUR_NEW_DOMAIN_WITHOUT_HTTP_HERE',
#secure_protocol = 'https://'; -- set to http:// if no certificate is available
UPDATE `core_config_data` SET `value` = CONCAT('http://', #shop_domain, '/') WHERE `path` = 'web/unsecure/base_url';
UPDATE `core_config_data` SET `value` = CONCAT(#secure_protocol, #shop_domain, '/') WHERE `path` = 'web/secure/base_url';
UPDATE `core_config_data` SET `value` = CONCAT('http://', #shop_domain, '/media/') WHERE `path` = 'web/unsecure/base_media_url';
UPDATE `core_config_data` SET `value` = CONCAT(#secure_protocol, #shop_domain, '/media/') WHERE `path` = 'web/secure/base_media_url';
UPDATE `core_config_data` SET `value` = #shop_domain WHERE `path` = 'web/cookie/cookie_domain';
You also have to clear the cache after those changes.
Do The Following
in production db,in its core_config_data table, you should find every records containing the url of your local installation, then you need to update those values
this query may help you
SELECT *
FROM `core_config_data`
WHERE `value` LIKE 'http://%';
Do not forget to delete var folder contents
Related
My wordpress uploads folder is structured in the default way (year/month)
I have successfully changed the uploads directory location.
But the problem is that I have 10000+ posts and I am looking for a solution so that I can also move the existing medias to the the new location.
I know doing this will also require me to change the path of the medias at the database level.
Does any one know any plugin or script for doing so.
Thanks.
There are a couple of different options mentioned here, most of them are either using an already configured plugin, or running SQL scripts.
Most useful answer that was on that link that I found involved changing the old URLs found on each wp table in your MySQL database
UPDATE wp_options SET option_value = replace(option_value, 'Existing URL', 'New URL')
WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET post_content = replace(post_content, 'Existing URL', 'New URL');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'Existing URL','New URL');
UPDATE wp_usermeta SET meta_value = replace(meta_value, 'Existing URL','New URL');
UPDATE wp_links SET link_url = replace(link_url, 'Existing URL','New URL');
UPDATE wp_comments SET comment_content = replace(comment_content , 'Existing
URL','New URL');
And keep in mind the MySQL replace command can replace part of the URL string, it doesn't have to replace the entire URL string. So in your case, if the original url was
'http://yourdomain.com/wp-content/uploads/2010/10/img.jpg' you could replace the URL as
UPDATE wp_links set link_url = replace(link_url, 'http://yourdomain.com/wp-
content/uploads/2010/10/', 'http://yourdomain.com/wp-content/uploads/') where
link_url like 'http://yourdomain.com/wp-content/uploads/2010/10/%'
You would have to do this for each year and month, but scripting it out this way would be a lot easier than manually updating every URL!
I want to use magento profiler for admin area. Is there any option in magento admin to do that or there is any other mysql query to do that?
i am using magento 1.8
Found that solution i run following mysql queries to do that:
select * from core_config_data where path like '%template_hints%' and scope like '%default%';
this query will output 2 rows set there value attribute from 0 to 1, if you get no records by the upper query run that follow query
INSERT INTO core_config_data (scope, scope_id, path, value) VALUES ('default', 0,'dev/debug/template_hints', 1),('default', 0, 'dev/debug/template_hints_blocks', 1);
to disable it change the value to 0 again
Magento Profiler and Template Hints are two different things.
To enable Profiler you need to uncomment Varien_Profiler::enable(); line found in index.php and set configuration in System > Configuration > Developer > Debug minding the current configuration scope.
To enable Template Path Hints in admin use this:
insert into core_config_data (scope, scope_id, path, value)
values ('stores', 0, 'dev/debug/template_hints', 1)
on duplicate key update value = 1 &~ value;
I have come up with the following solution:
CREATE TABLE logger (
id int(11) NOT NULL AUTO_INCREMENT,
ip int(11) NOT NULL,
landing varchar(16) DEFAULT NULL,
updated timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
See if entry exists
select id, landing from logger where ip = INET_ATON('10.0.5.9') and updated > date_add(CURRENT_TIMESTAMP,interval -2 DAY) order by id desc limit 1;
If exists update. This shall automatically update the updated field
update logger set landing = 'landing' where id = 1;
If not exist add the entry
insert into logger (ip, landing) value (INET_ATON('10.0.5.9'), '/');
Could anyone help me with the php bits to add into my headers as i have successfully sorted the MySQL bits now.
Thanks in advance guys!
A good solution would be to use a special URL that you would link to from email campaigns, where the "real" adress is added as query parameter:
Example which would redirect to http://example.com/foo
http://example.com/campaign.php?forward_to=http%3A%2F%2Fexample.com%2Ffoo&campaign=bar
In that script you set a cookie and forward to the actual address
<?php
setcookie('campaign', $_GET['campaign']);
header('Location: ' + $_GET['forward_to']);
?>
Note that this script needs to be on the same domain. You could also do this without a redirect by just setting up a hook in functions.php and looking for a campaign query sting parameter and serving different stylesheets based on that. Example:
(this assumes that you have campaign specific stylesheets located in mytheme/styles/ named campaign-1.css, campaign-2.css )
// in /functions.php
/**
* Sets cookie if 'campaign' var is passed in url
*/
function get_campaign_code($query_vars) {
if (isset($query_vars['campaign'])) {
setcookie('campaign_code', $query_vars['campaign']);
}
}
add_filter('query_vars', 'get_campaign_code');
/**
* Enqueue a campaign specific stylesheet if $_COOKIE['campaign_code'] is available
*/
function enqueue_campaign_stylesheet() {
$cid = $_COOKIE['campaign_code'];
if ( $_COOKIE['campaign_code'] ) {
// creates uri to campaign specific
$src = sprintf('%s/styles/campaign-%d.css',
get_template_directory_uri(),
$cid
);
wp_enqueue_style( 'campaign_css', $src);
}
}
add_action( 'after_setup_theme', 'function_name');
You should not use the ip to identify an user, use sessions instead (that is, use the cookie)
<?php
session_start();
//Set the correct page if not set already
if(!isset($_SESSION['page']){
if(userCameFromEmail)
$_SESSION['page'] = "someUrl1";
else if(userCameFromTV)
$_SESSION['page'] = "someUrl2";
else if(userCameFromCard)
$_SESSION['page'] = "someUrl3";
}
//Redirect
header("Location: " . $_SESSION['page']);
?>
This way the user will see the same page he saw the first time as long as he keeps the cookie. Keep present that this doesn't forbid access to the other urls. If you wan't to restrict access that's more difficult. You could add a different random code in each of your business cards, and ask for it in the page. Same goes for the email. The TV page is by definition public I guess you don't want to restrict access to it.
I had a project on localhost, now in wamp I setted virtual domain. Now the local project opens fine on domain address but resource files on pages are not loading. In source code of pages css and js files are still linked with 'localhost' hence are not found.
Its very simple
Edit wp-config.php
define('WP_HOME','http://example.com');
define('WP_SITEURL','http://example.com');
Edit functions.php
and add the line
<?php
update_option('siteurl','http://example.com');
update_option('home','http://example.com');
?>
Take care of permalinks .htacess file & database resources links
You can check here
In your wp-config.php, add these two lines.
define('WP_HOME','sitename/');
define('WP_SITEURL','sitename/');
Also, you need to edit the SQL file to change the resource locations.
I wrote this tutorial which shows you how to do that.
It's here, on my blog.
If you want to maintain your ability to upgrade WordPress in one click, never edit the WordPress core code. Instead, you can use their recommended (clean "drop-in") solution:
Create a new file at /wp-content/db.php with this content:
<?php
/**
* #see http://codex.wordpress.org/Running_a_Development_Copy_of_WordPress
*/
add_filter('pre_option_home', 'test_localhosts');
add_filter('pre_option_siteurl', 'test_localhosts');
function test_localhosts()
{
if (isDevEnvironment($_SERVER)) {
return "http://mysite.local/blog"; //Specify your local dev URL here.
} else {
return false; // act as normal; will pull main site info from db
}
}
/**
* Logic to determine the environment (dev or prod)
* #return bool
*/
function isDevEnvironment($serverArray)
{
return strpos($serverArray['SERVER_NAME'], 'mysite.local') !== false;//Edit this function such that it returns a boolean based on your specific URL naming convention.
}
Now, your local development environment will use its own base URL, and then when you deploy a copy of your codebase to a production environment, it will use its production base URL automatically.
Try this:
You need to change your local links to live links.
For that, Update your database with some query.
:: Queries to change URL for WP Website
UPDATE pvgc_options
SET option_value = replace(option_value, 'http://pleasantviewgarden.hideoutdev.co.uk/',
'http://pleasantviewgardencentre.com/')
WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE pvgc_postmeta
SET meta_value = replace(meta_value, "http://whynickoli.com/", "http://localhost/onestopproperty/");
UPDATE pvgc_posts
SET guid = REPLACE(guid, "http://whynickoli.com/", "http://sparsh-technologies.co.in/megha/onestopproperty/");
UPDATE pvgc_posts
SET post_content = REPLACE(post_content, "http://whynickoli.com/",
"http://sparsh-technologies.co.in/megha/onestopproperty/");
Here you should use your domain.
Thanks!
Edit the wp-config.php settings for a new domain:
define('WP_HOME','siteurl');
define('WP_SITEURL','siteurl');
Search and replace on the database with InterconnectIT Search and Replace Tool. With that tool it's easy to search through the entire database for all occurrences of old domain, and replace that with the name of new domain
my problems started when I moved my website to another folder (from /dev/ to /).
I have gone through the whole database in order to change all the hardcoded /dev/ into / but I still notice that wordpress, somehow, still uses the old values.
Basically the website uses information that are not there anymore.
I checked my own and the server cache and they all seem to be clean (the server doesn't even seem to have that feature on).
So, I am pretty much lost...
When you move a wordpress install, you need to change the site URL throughout your database. To do this you'll need to export your current database via PHP MyAdmin, and then use a tool like:
http://interconnectit.com/products/search-and-replace-for-wordpress-databases/
...to do a search and replace on the entire database.
Search for:
www.yourwebsite.com/dev
replace with:
www.yourwebsite.com
Then import the new database, open your Wordpress site via wp-admin and re-save permalinks.
Run this query in your database
set #oldurl = 'http://oldwp-url.com', #newurl = 'http://newwp-url.com';
UPDATE wp_options SET option_value = replace(option_value, #oldurl, #newurl) WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = REPLACE (guid, #oldurl, #newurl);
UPDATE wp_posts SET post_content = REPLACE (post_content, #oldurl, #newurl);
UPDATE wp_posts SET post_content = REPLACE (post_content, CONCAT('src="', #oldurl), CONCAT('src="', #newurl));
UPDATE wp_posts SET guid = REPLACE (guid, #oldurl, #newurl) WHERE post_type = 'attachment';
UPDATE wp_postmeta SET meta_value = REPLACE (meta_value, #oldurl, #newurl);