I have a site called www.example.com and I have my php files in it. I store all my working files in www.example.com/site. I want to view the site in www.example.com instead, without moving my site content. What can I do?
This is currently what I am typing in .htaccess. It will redirect my site to www.example.com/site but I think the url is ugly
RewriteEngine on
RewriteBase /
RewriteRule ^(/.*|)$ /magento$1 [NC,L]
Let me see if i understood this correctly.
You have a domanin, www.example.com, and on this domain you want to display the content of a directory, www.example.com/site !?
If this is the case then you need to change the document root
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.example.com$
RewriteCond %{REQUEST_URI} !^/site
RewriteRule ^(.*)$ /site/$1 [L]
or
RewriteEngine on
RewriteBase /
RewriteRule ^(.*)$ /site/$1 [L,NC]
There are 2 things you must consider :
If I understand your request, you are accessing some PHP files using www.example.com
, but what you want is to access www.example.com/site
, but without the /site
, right ?
So basicaly, what you're looking for is NOT rewrite, it's just pointing your domain to the good folder, which is /site
, right ?
/etc/apache2/site-available/default
(or remplace default
with the name of the virtualhost you may have created).In this file, look for the directive DocumentRoot
. It should lead to the "root" directory of your pages (the one you access typing www.example.com) I think you just have to append /site
to this DocumentRoot
and then reload your apache2 with service apache2 reload
You're website www.example.com
will now lead to the correct directory.
If it's still not working, you must consider looking into magento's admin, because magento is rewriting url according to the Base URL
you specify inside Admin / Configuration / general / web
. You'll have to modify Base_URL
in both Secure
and Un-Secure
sections.
Then it should work fine. I would comment out the Rewrite bloc you're using at the moment, or maybe I didn't fully undestand what you want to achieve.