I'm using OpenCart for my site. The icons fail to appear when you visit example.com but they do appear if you visit www.example.com.
Any ideas what is going on here?
I have just edited config.php file and removed www. and it works for naked domain but the icons do not load
// HTTP
define('HTTP_SERVER', 'http://example.com');
define('HTTP_CATALOG', 'http://example.com');
define('HTTP_IMAGE', 'http://example.com/image');
define('HTTP_ADMIN', 'http://example.com/admin');
I would redirect all non www traffic to www. This should take care of your issue with icons. It'll also prevent possible SEO issues as a result of duplicate content/pages.
If you have an apache server add a redirect to your .htaccess.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
What worked for me:
Go into the config.php file (please backup your file first) in the main directory of your OpenCart installation.
Under //HTTP (lines 5-8 for me), edit
lines:
define('HTTP_SERVER', 'http://example.com/shop/');
define('HTTP_CATALOG', 'http://example.com/shop/');
define('HTTP_IMAGE', 'http://example.com/shop/image/');
define('HTTP_ADMIN', 'http://example.com/shop/admin/');
to read:
define('HTTP_SERVER', '/shop/');
define('HTTP_CATALOG', '/shop/');
define('HTTP_IMAGE', '/shop/image/');
define('HTTP_ADMIN', '/shop/admin/');
.
Depending on your installation, I'm sure this could cause some problem somewhere I just haven't found it... yet... (maybe someone else could correct me -- I really don't mind; I like to learn).
This worked for me:
Add to .htaccess file this line: Header add Access-Control-Allow-Origin "your-domain.com"
Change "your-domain.com" required by the url.
If in our configuration file use: define ('HTTP_SERVER' 'http://example.com/);
Then place: Header add Access-Control-Allow-Origin "http://www.example.com/"
I tested this in opencart 2.0.
Related
I am trying to do 301 redirect in my herokuapp. How can I do it. I have used <link rel="canonical" href="http://mysite.herokuapp.com">. And I have also used this tag for every page with the url of the page. Still I failed to fix 301 redirections problem in my heroku website.
With url http://mysite.herokuapp.com website is working but with url
www.http://mysite.herokuapp.com it shows
This site can’t be reached
Yoast seo shows this message
"Warning, no 301 redirects are in place to redirect traffic to your
preferred domain. Pages that load successfully both with and without
www. are treated as duplicate content! "
For this problem my website is not indexing in google, I think. How can i show my website in google search.
Note: I have submitted my website to google search console and verified it.
Please help me to solve this problem.
You will want to use something called htaccess
There should be a file in the root of your web directory called ".htaccess" If not create one.
You want a rule something like this:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.mysite.herokuapp.com [NC]
RewriteRule ^(.*)$ http://mysite.herokuapp.com/$1 [L,R=301]
This should redirect www traffic to a none www prefix
So first off, I am pretty familiar with codeigniter I've used it for multiple occasions. Right now I have a project too do for school and I installed codeigniter on the server but I am getting routing issues I believe.
So additional info about the server which is different from the normal environment I work with, the server uses SSH and it is very weirdly protected in my opinion. You also need a username and password to view the URL in the first place. (I think it's weird)
If this helps the url is:
https://clipper.encs.concordia.ca/~pyc353_2/
and credentials are (username: pyc353_2, password: FMaqRb)
Now I am able to see any page that I set as my 'default_controller' in the routes, but the problem is trying to go to any other page. Right now I'm trying to access the register controller and I just get 404'd (while it works if I set it as default)
I will link all the code I think may be relevant to the error, hopefully it's not server settings since I have no control over any change.
config.php
$config['base_url'] = 'https://clipper.encs.concordia.ca/~pyc353_2/';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
routes.php
$route['default_controller'] = "test";
.htaccess (there may be better code for doing this but I used it in the past no problem and the route doesn't work even if I remove htaccess and add back index.php to 'index_page')
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
</IfModule>
So I tried accessing my pagedifferent variations in the url such as: (stackoverflow won't let me post more than 2 physical links)
clipper.encs.concordia.ca/~pyc353_2/register
clipper.encs.concordia.ca/~pyc353_2/index.php/register
neither work although with /index.php/ the error message is: "No input file specified."
So I hope my explanations are clear enough, it's hard to explain something I don't understand the source problem. If you need any additional info feel free to ask. I really need to solve this to proceed at all for my project.
EDIT
I don't know if this is relevant but the 404 message is not even in the codeigniter style it just looks like a plain web 404
Also I am looking at the path on the server and this is the hierarchy: /www/groups/p/py_comp353_2 I don't know if that could affect anything also?
NEWER EDIT
Following what I found here: http://ellislab.com/codeigniter/user-guide/installation/troubleshooting.html
Changing index.php to index.php? (and removing htaccess) actually did make the routing work. Now I am happy enough with this and I can continue working, but being that it's an ugly solve would anyone know how to keep the routing working AND remove the index.php? from my URI?
It appears that your htaccess is not working.
To confirm, create a new PHP file and write this line:
echo phpinfo();
On that page try to search for "mod_rewrite", if it is enabled, you will see it under "Loaded Modules"
It is probable, it is not enabled.
Try this on your server:
a2enmod enable
Then restart the apache server.
For restarting on debian, this should work:
service apache2 restart
For CentOS, this should work:
apachectl restart
That always does not solve the problem.
Even then, try your CI installation in the normal mode after that. (With everything in normal mode: htaccess as before, and no index.php in the URL)
If it does not work, you may need to alter the apache config file httpd.conf
Try to search for this line:
#LoadModule rewrite_module modules/mod_rewrite.so
Uncomment it by removing the # sign
Restart Apache Server.
Test it now, again.
There could still be other things that you could do to enable mod_rewrite.
I have Linux webhosting on Godaddy. I tried installing Magento CE 1.8 on subdomain for more than a week and I still cannot get it to work.
Before you say this question is duplicit, I have tried everything I found on Magento Wiki, Forums, Google and Godaddy forum and support and I still cannot get it to work.
For php5.ini I take Magento php.ini.sample, .htaccess is from Magento too.
Using Options -MultiViews in .htaccess usually doesn't do anything.
Settings cgi.fix_pathinfo = 1 in php5.ini creates cyclic redirect.
I have tried playing with RewriteBase in .htaccess and that didnt help either.
I read that Magento doesnt run on fcgi, so I use in my .htaccess, doesnt help either:
Options +ExecCGI
addhandler x-httpd-php5-cgi .php
I always end up with "No file input specified" or cyclic redirect or server error.
Only lines in error log that I see are added:
[Thu Oct 31 01:23:08 2013] [11988011] [negotiation:error] [client 5.178.58.85:65433] AH00687: Negotiation: discovered file(s) matching request: "path" (None could be negotiated).
But I dont know what that does mean or how to fix that.
So is there anything else I can try or am I missing something? I know Magento on Godaddy shared hosting isnt a good idea, but I need to get there my development running and production will run on my clients Dedicated server.
Add this to your .htaccess file and forgot those other fixes....
RewriteRule ^index.php/(.*)$ [L]
If magento lies in a subdirectory then use:
RewriteRule ^index.php/admin(.*) {RewriteBase}/admin$1 [L]
So I managed to solve it after few weeks of trying different solutions on net and trying to get support to help me.
Nothing helped solve it so I tried myself and found out that the problem is "index.php" in url. So I have created simple php function which is run in at the beginning of index.php file. This function removes "index.php/" from url and redirects to this new url.
Also to remove "index.php" from form actions and other places where the url might show up, it is good to create your own router module or modify Magentos router.
Now it all works.
PS:
I have also kept other fixes in place:
In .htaccess:
Options +ExecCGI
AddHandler x-httpd-php5-cgi .php
AddHandler x-httpd-php5-cgi .php5
Options -MultiViews
RewriteBase /
And in php5.ini
cgi.fix_pathinfo = 1
EDIT
What I wrote does work, but is not good solution, redirect in index.php loses all POST data ofcourse. And looking at Magento and changing router takes too much work, so in the end I managed to create working rule in .htaccess for admin. Just put it as last rewrite rule in your .htaccess:
RewriteRule ^index.php/admin(.*) /admin$1 [L]
EDIT
Forgot to write here, that I have changed the rewrite to this:
RewriteRule ^index.php/(.*) /$1 [L]
I need to do a mass 301 Redirect for all pages ending with .html for my site. I am looking to move all the old .html files to a sub-folder ir.
RedirectMatch 301 (.*)\.html$ http://www.domain.com/folder/$1.html
When I add this and refresh the browser I get a ton of folder/folder/folder now after the url ie
domain.com/folder//folder/folder/folder.....
Any ideas what could be wrong?
Thanks if you can help
The problem is, that 'folder/foo.html' also matches the condition of the RedirectMatch and folder is appended again (and again, and again ...)
Therefore you probably need something like this (untested):
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/folder/
RewriteRule (.*)\.html$ /folder/$1.html [R=301,L]
The RewriteCond should check that the URI doesn't start with /folder and only if this condition is met, the RewriteRule will be checked.
Unfortunately I haven't any Apache installation available at the moment for testing such things, so you will probably have to try it on your own. But I hope you got the idea.
If your old html files are in the root, I would suggest the following:
RedirectMatch 301 ^([^/]+)\.html$ http://www.domain.com/folder/$1.html
My problem is that i have a functioning subdomain (sub.mydomain.com). sub is loaded in mydomain.com/sub.
What i would like to do is to redirect all requests to sub.mydomain.com to mydomain.com.
Somehow it seems that when im the subdomain i cannot access the rootfolder (main domain). I can get it working with from mydomain.com/sub to mydomain.com. But not from the subdomain.
Currently im using:
RewriteEngine on
RewriteRule ^(.*)/?$ /home/web/webuser/$1 [L]
When accessing sub.mydomain.com i get a 500 Internal Server Error.
Is there a restriction in accessing the main from a sub? (rights wise)
Or maybe another way of getting to main, perhaps something like (../$1)
Thanks
EDIT:
I only have access to .htaccess. So DocumentRoot cannot AFAIK be used in .htaccess file.
What about symlinks? I dont really know what it does, but i assume that it links two locations? The only code i found for that enables symlinks (Options +FollowSymlinks) - but this line doesnt say anything about what to link (perhaps im all wrong)
Btw. thanks for input so far !
I must admit that I did not fully understand your question. Do you want to redirect everything from sub.mydomain.com/whatever to mydomain.com/whatever? In that case, the following (put in the config file of your sub.mydomain.com) might work:
RewriteEngine On
RewriteRule ^/(.*)$ http://mydomain.com/$1 [R,L]
It redirects on the client side, meaning that the user will see mydomain.com/sub in the browser.
EDIT: I think I understand your question now. Yes, it's a permissions issue: If the DocumentRoot of your web site is /whatever/sub, then you cannot just access /whatever by adding "/.." to the URL. I hope you understand that this is a good thing. :-) mod_rewrite just changes the URL, so it cannot do that either.
So, to solve your problem, you need to either change the DocumentRoot of sub.mydomain.com or create a symlink that allows you to access the required directory (e.g. /whatever/sub/redir-target -> /whatever). Be careful with the symlink option, though, since it will create valid directories of infinite length on your file system (/whatever/sub/redir-target/sub/redir-target/...) and some scripts cannot cope with that.
EDIT2: Instead of a symlink, you might want to create an alias, e.g., something like this:
Alias /redir-target /home/web/webuser
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/redir-target/.*$
RewriteRule ^/(.*)$ /redir-target/$1
Still, I think the easiest solution is to change the DocumentRoot...
Why not try using a Redirect Directive from mod_alias?
It's difficult to provide a definitive answer without knowing more about your server configuration.
The following might work and is at the very least a decent starting point:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^sub\.mydomain\.com
RewriteRule (.*) /$1 [L]
Ideally that would go in your httpd.conf, but might work from a .htaccess file (again, more information about how your subdomains are setup would be helpful).