How to make Magento run in my subdomain - php

I'm trying to build a Magento (1.9.3.1) staging site in a subdomain but can't get it to work properly. The site is working but no images, js or css files are being loaded. I've searched around but all the answers I've found don't work for me.
My main website structure is www.domain.com which has it's own website (not Magento) but then I have subdomain.domain.com with Magento installed.
Following another answer I tried editing .htaccess and added the following:
RewriteCond %{HTTP_HOST} ^subdomain\.domain.com$
RewriteRule ^/(.*) http://subdomain.domain.com/index.php [L]
but that didn't work. I tried different variations of that too.
Any ideas what I'm doing wrong? I have a dedicated server and the domain structure is:
/httpdocs
/subdomain.domain.com
where the main website root is in httpdocs. Could that be the issue?
The subdomain is set correctly in the core_config_data table as well.

Most packages like magento require root access.. this may be the issue.
Also, try to check the path to youre images.

Okay #Olcan set me in the right direction so thanks. It wasn't actually root access needed but directory permissions were not set correctly.
All the directory permissions were set to 750. Changed them to 755 and everything works. Didn't need to do anything with .htaccess either so I left it at the default
RewriteRule .* index.php [L]
and it works.

Related

migrating htaccess from localhost WAMP to godaddy subdomain

First off this is similar to other stack questions however none of the solutions helped me. so before your mark as duplicate, or whine about the question try look for solutions and not problems with the question.
Hi all, here's the scoop, I have tried to be thorough.
I have a site that is in mid development.
A potential employer wants to check out the site in its current state.
In order to do this I had to put it as a sub domain of a site I already have hosted with GoDaddy.
the site uses pretty urls that link to php scripts in various directories.
mysite.com/location
would, via htaccess rules go to a script at
mysite.com/src/script/php/location/location.php
or another example might be
****mysite.com/location/fj83jfd83****
would, via htaccess rules go to a script at
mysite.com/src/script/php/location/location.php?item=fj83jfd83
my htaccess file works on my local WAMP stack but not once on the remote goddady server hosted with linux cpanel
my htaccess file is as follows
RewriteEngine On
RewriteBase /
AddDefaultCharset utf-8
RewriteRule ^location/([A-Za-z0-9]+)/?$ src/script/php/location/location.php?item=$1 [NC,L]
RewriteRule ^location$ src/script/php/location/location.php [NC,L]
Question one
I am wondering what changes do I need to make to the htaccess file for this to work on the GoDaddy server on a subdomain like mysite.hostedsite.com?
Question 2
would the htaccess go in the base public root folder or the subdomain root folder?
Couple things to note.
I am open to options that don't use htaccess or another work around that hasn't occurred to me.
This is only for someone to view the site, so a short term patch(hack) solution is fine, the site is not ready for launch.
thanks you in advance
All I needed to do was add the subdomain to the start of the rewrite rule.
so
RewriteRule ^location$ src/script/php/location/location.php [NC,L]
needed to be
RewriteRule ^mysite/location$ src/script/php/location/location.php [NC,L]
just left it encase it helps any one in the future!

Using .htaccess to rewrite to Wordpress subdirectory?

As opposed to many questions here in StackOverflow, I'm looking for something a little different. I have a Wordpress install in a subfolder of my domain called "blog". The main part of the website is a Magento website. I'm looking to take any instance where "blog" is part of the URI, and make sure it's untouched by the myriad of other RewriteRules in Apache.
As a few examples:
http://www.example.com/blog/wp-admin/
http://www.example.com/blog/
http://www.example.com/blog/save-money-groceries-without-coupons/
...should all direct to the Wordpress site found under /blog/
http://www.example.com/
http://www.example.com/plumbing/faucets.html
http://www.example.com/about/family-history.html
...should all direct to the Magento site that is currently found under the root directory
What is the best practice in writing the .htaccess file to achieve this result?
To redirect http://www.example.com/blog/wp-admin/ to http://www.blog.example.com/wp-admin/ you can add the following to the .htaccess file
RewriteEngine On
RewriteRule ^blog/(.*)$ http://www.blog.example.com/$1 [L,R=301]
I'm not an expert on setting up Apache servers but I think you want your WordPress install in a completely different folder to Magento and then use Alias in your .conf file. You can read about the Alias directive here.
For example in my Apache .conf files I have
Alias /blog/ "/full/path/to/wordpress/htdocs/"
This way the folder /full/path/to/wordpress/htdocs/ has its own .htaccess and its own index.php - which is what you are going to want for running WordPress without jumping through hoops.
Remember to restart Apache if you update the .conf file.

Redirect directory to subdomain cpanel

Alright I have already contacted BlueHost Support and they couldn't figure out how to fix this issue. I've also tried to use cpanels 301 permanent redirect but that doesn't work so I decided to give it a whirl on here.
I host with BlueHost.com if you haven't caught that by now. The file structure is as follows:
public_html/
directory1/subdomaindirectory
directory2
directory3
I have my main website in my root (public_html). Then I have to create new directories and assign the url to that directory. So essentially if you typed in www.maindomain.com/directory1 it would show the website in the directory. I would like to modify the .htaccess to redirect that to it's original domain so www.maindomain.com/directory1 would go to www.directory1.com
The same for subdomains. I created subdomain.directory1.com and pointed it to public_html/directory1/subdomaindirectory and if you go to www.directory1.com/subdomain it pulls up the site.
I realize theoretically it's the same thing but it bugs me that you are able to pull up a website like that.
Is there anyway to modify the .htaccess to fix this issue?
In.htaccess you could do it like this
RewriteEngine On
RewriteBase /gorbox
RewriteCond %{HTTP_HOST} ^www.gorbox.com$ [NC]
RewriteRule ^support$ http://support.gorbox.com [L,R=301]
Put this in the .htaccess file that resides within the root folder of www.gorbox.com

mod_rewrite bug and permission denied

i'm using mod_rewrite to rewrite sites like "url.com/foo" to "url.com/index.php?site=foo".
The Code:
RewriteEngine On
RewriteBase /
RewriteRule ^([0-9a-zA-Z]+)$ index.php?site=$1
If i click on a link with href="/foo" it will give me
http://url.com/foo/?site=foo
The code works at other sites on the same V-Server, i have Boilerplate installed, BUT i dont use the .htaccess of it right now to fix the mod_rewrite, so it cant be a boilerplate issue, or?
I also tried the following code:
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)$ index.php?site=$1
That code, at least, rewrites to index.php?site=foo
BUT it still creates url's like the upper example with the unnecessary folder between.
Edit: to make sure everyone understands the overall idea:
The files are based in http://url.com (index.php, .htaccess) , so i set the RewriteBase to "/".
It should take links like
http://url.com/foo
and rewrite them to
http://url.com/index.php?site=foo
there are no folders included.
I solved it, damn i'm so stupid ;)
I have a folder called url.com/foo/ and the link im redirecting is url.com/foo to url.com/index.php?site=foo so it is always trying to get into that folder. Since i renamed the folder it is working very well.
I have been getting a similar error message on RewriteRule
pcfg_openfile: unable to check htaccess file, ensure it is readable
I also have the subfolder name similar to the redirected URL part but renaming it did not solve the problem (as suggested by Chris).
After multiple attempts, the problem was solved by updating the subfolder permissions to 755 (using cPanel folder permissions dialog) :
User: Read, Write, Execute
Group: Read, Execute
World: Read, Execute
PS: I am not sure if renaming the subfolder was actually required for this scenario since before and after the rename, error message was same.

how do i hide /magento/ in my site's url?

A site has an existing system (lets call it mysite)
and the client asks to put in magento.
My directory structure goes something like this:
ROOT
-index.php (this is the app's main controller)
-.htaccess
/blog (runs wordpress)
/assets (current system's media folder)
/magento (this is where all magento files go)
Problem is if I set up magento and specify in the installation that base URL is http://example.com, magento loads up mysite.
Leaves me no choice but to setup magento with base URL set to http://example.com/magento/ and it runs perfectly.
However the client wants me to feel hell and asks me to hide magento in the URL.
I’m not really versed in .htaccess and I know only simple rewrite codes so I tried forwarding any HTTP requests that start with /magento to the magento folder and came up with:
RewriteCond %{REQUEST_URI} !^/magento(.*)
RewriteRule (.*) /magento/$1 [L]
Just when I thought it was working, mysite links all became unaccessible and forwards to the magento system displaying it's 404 page.
So, uhm, can I ask for help how to construct the .htaccess to hide the /magento/ on the URLs without affecting the current system aka mysite?
Because you have existing applications off the webroot, you cannot get away with using nothing instead:
### webroot/.htaccess
RewriteRule ^whatiwanttouseinsteadofmagento/(.*)$ magento/$1 [L]
From how I see the problem you will not be able to hide magento completely and use your site as well in the same time.
If you want Magento in the root of the public folder you should just point the virtualHost to your magento installation but this will let your blog and your main controller out of the public view. This is more or less the same with what you did by redirecting all calls in the .htaccess to magento folder.
What I suggest is to change the magento name to something more anonymous like "shopping" or "cart", and remember that a folder rename is preferable to a .htaccess file in terms of security and performance.
Let's look at it:
RewriteCond %{REQUEST_URI} !^/magento(.*)
So we're saying the condition is anything that is not /magento(.*), so everything but that directory? This would redirect everything, including your blog, assets, and any other directories.
Without specifying each and every file that needs to be redirected to the magento directory, there really is no easy way of doing it. I suppose you could redirect any file that does not contain a "/" in it and ends with the extension .php to the magento directory. That way only files in the root web directory will redirect to magento, but if you used other directories inside the magento directory you'd still need to add separate rules for them.
this answer comes very late but I guess you wanted something like
RewriteCond %{REQUEST_URI} !^/(blog|assets|magento)(.*)$
RewriteRule ^(.*)$ /magento$1 [L]

Categories