I'm just launching my first Magento store (on CentOS & Apache) and I've switched over from my setup subdomain - http://prelive.mydomain.com (where everything worked fine, with url rewriting enabled & working) - to the live subdomain http://www.mydomain.com, basically just by doing the following:
clearing caches via the admin interface
updating the secure & unsecure base urls in the db
UPDATE core_config_data SET value = 'http://www.mydomain.co.uk/' WHERE path = 'web/unsecure/base_url';
UPDATE core_config_data SET value = 'https://www.mydomain.co.uk/' WHERE path = 'web/secure/base_url';
moving the entire site file system from /var/www/html/prelive to /var/www/html/www (I tried copying but it caused all sorts of permission problems which I'll figure out later!)
manually editing the media base path in var/resource_config.json
updating my virtual host like this:
<VirtualHost *:80>
DocumentRoot /var/www/html/www
ServerName www.mydomain.co.uk
ServerAlias www.mydomain.co.uk
ErrorLog logs/www.mydomain.co.uk-error_log
</VirtualHost>
editing the base .htaccess file like this ()
SetEnvIf Host www\.mydomain.co.uk MAGE_RUN_CODE=angling_r_en
SetEnvIf Host www\.mydomain.co.uk MAGE_RUN_TYPE=store
SetEnvIf Host ^mydomain.co.uk MAGE_RUN_CODE=angling_r_en
SetEnvIf Host ^.mydomain.co.uk MAGE_RUN_TYPE=store
And it almost works... but the url rewriting is broken. I can see the site on http://www.mydomain.com but navigating to subpages gets a 404 (e.g. http://www.mydomain.com/path/to/product.html ), unless I specifically alter the URL to point through index.php like this http://www.mydomain.com/index.php/path/to/product.html or http://www.mydomain.com/index.php/admin
For reference, in .htaccess I also have (left unchanged during the switch of subdomain):
RewriteBase /
and
RewriteRule .* index.php [L]
Any thoughts on what I forgot?
Many thanks
Ben
Most likely you need to reindex the catalog URL rewrites to incorporate your new URL changes! See System > Index Management and reindex the Catalog URL Rewrites.
Ok - so the problem was on the server all along, not Magento...
Basically rewrites weren't working because I needed this in both my VirtualHost container in both both httpd.conf and ssl.conf:
<Directory /var/www/html/www>
AllowOverride All
</Directory>
What I still don't understand is how it worked on the old location (which definitely didn't have this) and not the new one... but it works just the same as before now, with "Use Web Server Rewrites" turned on in System > Configuration > Web, creating "clean" urls which are rewritten through index.php by mod_rewrite.
Related
hi I have many sites that I want to test on local, so when I edit the files on auto virtual host files under Apache->sites-enabled->file name, after reloading laragon, the file resets to its original default contents, ex-
Original
<VirtualHost *:80>
DocumentRoot "C:/laragon/www/cast.see.tech/public"
ServerName cast.see.tech.test
ServerAlias *.cast.see.tech.test
<Directory "C:/laragon/www/cast.see.tech/public">
AllowOverride All
Require all granted
</Directory>
edited
<VirtualHost 192.168.1.101:80>
DocumentRoot "C:/laragon/www/cast.see.tech/public"
ServerName cast.see.tech.test
ServerAlias *.cast.see.tech.test
<Directory "C:/laragon/www/cast.see.tech/public">
AllowOverride All
Order Deny,Allow
Allow from all
Require all granted
</Directory>
I cannot save any rules, any code, it comes back to its default original content once I restart laragon server. I am using windows 11, but the same problem I face on windows 10 also.
I tried uninstalling and installing back, but still no luck. Currently i am using latest version of laragon 5.0.0 210523, I also tried downgrading the version but still the same problem. Is it a windows issue or do I need to do something else. Please help me with this issue.
Each project has each own Virtual Host file located in:
For Apache:
{LARAGON_ROOT}\etc\apache2\sites-enabled\auto.{project}.test.conf
For Nginx:
{LARAGON_ROOT}\etc\nginx\sites-enabled\auto.{project}.test.conf
Content of a .conf file is auto generated. If you have a specific project which has modified content, just remove the auto. prefix from config file names eg : auto.example.test.conf => example.test.conf , Laragon will keep the content of the .conf file intact.
Virtual Host content is configurable, you can change it by modifying the template in:
{LARAGON_ROOT}\usr\tpl\VirtualHost.tpl
https://laragon.org/docs/pretty-urls.html
Laragon uses a template to auto-generate the virtual hosts.
On windows, the file is located at C:\laragon\usr\tpl\VirtualHost.tpl, assuming you installed it in C:\laragon.
Just edit this file and make the changes you want.
Keep in mind that all your sites will now use the same configurations.
One change I personally make is to remove the *. from ServerAlias, as I use subdomain format for my sites. Before I remove it, subdomain.example.com would always redirect to example.com.
I'm having troubles setting up a moodle instance behind an apache proxy.
Here's my apache front-end that proxies to the running server.
<VirtualHost *:80>
ServerName public.domain.com
ProxyRequests Off
ProxyPreserveHost On
ProxyPass / http://10.10.10.10:81/moodle/
ProxyPassReverse / http://10.10.10.10:81/moodle/
</VirtualHost>
AND.
$CFG->wwwroot = 'http://public.domain.com';
I install without problems, but when finished the installation I try in browser:
http://public.domain.com
This redirect to: http://public.domain.com/moodle/index.php?sessionstarted=1&lang=en...
Does anyone know what might be happening?
The best way to fix this issue is to move the moodle installation on the internal host to the root of web server.
Move your moodle in 10.10.10.10 to be at / and not at /moodle
Note, that if you will use SSL on the external apache (it's suggested) you should also add to your config this line:
$CFG->sslproxy = true;
Finally I have been able to fix the problem, I am writing this answer with a bigger level of detail so other people having this problem can follow my answer.
First we need to edit the apache2 config for our site:
In general the apache2 configuration for your specified site can be found at /etc/apache2/sites-enabled. Depending if you are using http or https you need to edit the right configuration file. Default name for http is 000-default.conf and for https 000-default-ssl.conf
Add the following lines between the <VirtualHost *:80>....</VirtualHost> sections.
# MOODLE
ProxyRequests Off
ProxyPreserveHost On
ProxyPass "/" "http://10.10.10.10:81/moodle/"
ProxyPassReverse "/" "http://10.10.10.10:81/moodle/"
Then we need to restart our apache2 webserver, this can be done with the command service apache2 restart.
Now we also need to edit a few things in our moodle config.php file. This file can be found at /var/www/html/moodle on the server with the IP (in this case) 10.10.10.10 if you used the default install location from the moodle guides.
In the config.php file we append the following lines under the default $CFG declarations: Please make sure to change all values according to your server setup.
$CFG->wwwroot = 'http://public.domain.com';
$CFG->dirroot = '/var/www/html/moodle';
$CFG->reverseproxy = true;
//$CFG->sslproxy = true; //UNCOMMENT this line if you are using SSL
Attention: If you are not using the root directory at your public webserver, then make sure that you do not use the same directory as moodle is using on the subserver. For example http://public.domain.com/moodle will fail if moodle is installed on the subserver at /var/html/moodle since both directories are equal and the proxy loops for some reason. My easy fix for this problem was do just move the moodle installation to /var/html/moodley including all required changes in the config.php. This fixes every problem I had.
I'm trying to set up CakePHP 2.x in Cpanel (Hostmonster) while the domain of the site is still pointing to the older server. In order to pull up the site without the domain (for demo), I have to use http://[hosting-IP-address]/~mysite.
This is my default .htaccess file located in the root (the one before app/ folder):
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
If I leave it as it is, I get 404 error. When I remove the .htaccess file or leave it blank, the site content loads, but without CSS. The site files are located in /home2/mysite/public_html/ folder. I tried adding RewriteBase with different combinations (~mysite, mysite, mysite/public_html), but no avail.
I have tried with rewrite base setting then i get 500 internal server error. Please suggest
Instead of changing your site .htaccess code. I will suggest you update your local pc host file to point your site to new server, so that you can check your all URL.
Open your hosts file which is located at : c:\Windows\System32\Drivers\etc\hosts and add the following code with your new hosting IP address
hosting-IP-address www.domain.com
hosting-IP-address domain.com
I'm trying to get mod_rewrite to work on OSX Lion.
By default, Lion loads the mod_rewrite module.
In my /etc/apache2/users/neil.conf I include the following:
<Directory "/Users/neil/Sites/">
Options Indexes MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
But whenever I visit a page locally, I get the message: The requested URL /some-page/ was not found on this server.
Can you access the page if you visit domain.com/index.php/some-page instead of domain.com/some-page?
If so, this could be an htaccess issue. Consider checking out EE's documentation on using an htaccess file to remove index.php from the URLs
I have a localhost setup(i use apache's virtualhost setup) for a site I am working on with codeigniter. I use SVN for the site.
I decided to change the localhost-domain name and the root-folder name(this is the folder from within which I check out SVN) to which the localhost-domain points.
To show a better picture, I changed;
sledge-vicky.localhost to hammer-vicky.localhost
Changed the document-root's name from "sledge" to "hammer". Have changed the document root,directory paths in the virtualhost setup too;
<VirtualHost hammer-vicky.localhost>
DocumentRoot D:\xampp\htdocs\vicky\projects\hammer
ServerName hammer-vicky.localhost
<Directory "D:\xampp\htdocs\vicky\projects\hammer">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Have set the domain-name in windows' hosts file. Have set/changed the base-url and database settings in config.php and database.php too(I use environment dir; _environment/vicky/config.php, _environment/vicky/database.php ).
In the code where we switch to the required app-environment, I have set the code to switch to my app-environment too.
http://sledge-vicky.localhost/ was working fine.
After the local-domain name and root-folder name change, accessing http://hammer-vicky.localhost/ throws a '404 page not found error'.
Any idea what could be wrong?.
My bad debugging. I got it working. I had to change other settings in some files specific to my environment (in my case, /application/config/_environment/...) that were related to some global settings(which in my case, others sharing the same svn-repository had changed).