Hi I have installed prestashop in a sub-folder
www.mydomain.com/store so the visitors have to enter the whole url to acces the prestashop. I dont want prestashop to be in the root domain.
I found this rule for htaccess and works well
RewriteEngine on`
RewriteCond %{HTTP_HOST} ^(www.)?mydomain.ee$
RewriteCond %{REQUEST_URI} !^/prestashop_subdir/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /prestashop_subdir/
RewriteCond %{HTTP_HOST} ^(www.)?mydomain.ee$
RewriteRule ^(/)?$ prestashop_subdir/index.php [L]
so now with this settings my visitors access the store using www.mydomain.com (they redirected to the sub-folder)
BUT on the addres bar appear (they see) www.mydomain.com/store
I just want that my visitors access www.mydomain.com access the store automatically, but dont see the store subfolder on the address bar. (where the prestashop is installed)
example:
www.mydomain.com (visitor enter on address bar)
they be redirected to the store so can access it
but on the url they can still see www.mydomain.com
PD. I copied the htaccess and index.php from prestashop sub-folder installation to the domain (www.mydomain.com)
Any help would be apreciated
Related
I am trying to get my subdomain to show the article path as well but it won't work.
if I go to blog.domain.com, it redirects to https://www.domain.com/blog/
I want https://www.domain.com/blog/ to stay blog.domain.com
and if I go to https://www.domain.com/blog/article/1 to show blog.domain.com/article/1/
With godaddy's cpanel, I added the subdomain forwarding (without masking - as it was always showing blog.domain.com and I want to see the path so I removed the masking)
I tried:
RewriteCond %{HTTP_HOST} ^(www\.)domain\.com$
RewriteRule ^blog/(.*)$ http://blog.domain.com/$1 [L,R=301,QSA]
RewriteCond %{HTTP_HOST} ^blog\.domain\.com$
RewriteCond %{REQUEST_URI} !blog/
RewriteRule ^(.*)$ blog/$1 [L,QSA]
This did not seem to do anything..
EDIT
I placed the htaccess only in the root folder.
And I also tried
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$
RewriteRule ^blog(.*)$ http://blog.domain.com/$1 [L,R=301,QSA]
when i go to blog.domain.com it redirects to www.domain.com/blog/ and the page does not load
I have it set to: when going to blog.domain.com -> redirect to www.domain.com/blog
This is why your browser's location bar is changing. When you redirect, the server is responding to the browser by saying "What you're looking for is not at the URL you just went to, it is at (in the case of 301, permanently) this NEW URL", so the browser loads the new URL, sending an entirely new and separate request to the new URL. That causes the location bar to change.
Turn off that redirect.
Then you should be able to leave the rule that you have in the root folder for your main domain:
RewriteCond %{HTTP_HOST} ^(www\.)domain\.com$
RewriteRule ^blog/(.*)$ http://blog.domain.com/$1 [L,R=301,QSA]
You don't need to mess with that other rule since your *document root for the blog.domain.com is already /blog/.
I use a hostmonster account to host several websites. Each site lives in a subdirectory of my public_html folder in order to keep me sane when administering the sites. So for example my primary domain lives in public_html/joshorndorff.com
I have set up my .htaccess file in my public_html folder to redirect traffic into the appropriate subdirectory as suggested by https://my.hostmonster.com/cgi/help/347
# .htaccess main domain to subdirectory redirect
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?joshorndorff.com$
RewriteCond %{REQUEST_URI} !^/joshorndorff.com/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /joshorndorff.com/$1
RewriteCond %{HTTP_HOST} ^(www.)?joshorndorff.com$
RewriteRule ^(/)?$ joshorndorff.com/index.php [L]
Then in my subdirectory I use the drupal default .htaccess as uncomment the lines that redirect to the www. subdomain. The relevant lines from the subdirectory are:
RewriteCond %{HTTP_HOST} ^joshorndorff\.com$ [NC]
RewriteRule ^(.*)$ http://www.joshorndorff.com/$1 [L,R=301]
This all works fine, but there are two problems I still have.
When I type www.joshorndorff.com/joshorndorff.com/index.php no rewriting happens and the domain name and subdirectory (which is named the same as the domain name) both show up in the address bar
When I enter my static ip address (67.20.112.212) in the address bar I am not redirected to my site, but rather I see the index.html that I put in public_html for testing purposes/
I've read the excellent tutorial on mod_rewrite at http://www.addedbytes.com/articles/for-beginners/url-rewriting-for-beginners/ but still can't get either of the two issues fixed. I would love any suggestions or working code, but even more would love to understand why
RewriteRule ^joshorndorff.com/ / [NC]
does not do what I expect.
Thanks so much!
-Josh Orndorff
In the examples I provided below I replaced your domain with example.com.
# 1
The way you have the rewrite condition/rule written this is expected behavior. To prevent it from happening, you need to add another condition/rule set that matches the specific subdirectory and rewrites it. This must be added before your other rule within the Drupal .htaccess file in your subdirectory.
Otherwise, you're basically telling it to match the domain name, and pass everything else as your first variable: $1, including the subdirectory.
Here is an example using example.com/example.com/index.php:
RewriteCond %{HTTP_HOST} ^example\.com\/example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
# 2
Your second issue, browsing by IP, is happening because your rewrite rules only matches your domain name.
If you want to redirect the IP to your site's domain name, you would need match the host, in your case the IP address, then rewrite to your domain:
RewriteCond %{HTTP_HOST} !^(.*)$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
If you truly want browsing by IP to work, you could do something like this:
RewriteCond %{HTTP_HOST} !^(.*)$ [NC]
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [R=301,L]
Please note that in addressing #2, you would have to adapt the rules I showed in #1 for use with IP address, and still match the subdirectory. Additionally, my examples aren't exact replacements for your rules, but should show enough for you to adapt it fairly easily. You might be able to just add your URI and file conditions to #1, but I did not test it specifically.
I want to move my website to a subdomain, but without hurting my SEO and backlinks.
so http://www.website.com/category/page
would become http://subdomain.website.com/category/page
I was thinking of making htaccess forward to the subdomain, but with the /category/page still in the url.
How can this be done?
Add this to the htaccess file of your www.website.com document root:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?website\.com$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://subdomain.website.com/$1 [L,R=301]
You can also redirect traffic to the subdomain if you have access to the control panel of the website.
For example, if you are using a cpanel, click on redirection and point the main domain(www.abc.com) to the subdomain(subdomain.abc.com)
I run TYPO3 with a normal site and a subdomain in the same TYPO3 installation. On the normal site, automatically a mobile device is detected and then rerouted to the subdomain.
In my subdomain the visitor is redirected to the correct page in the TYPO3 tree, using following .htaccess file.
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{http_host} ^m.mysite.com [NC]
RewriteRule ^(.*)$ http://m.mysite.com/index.php?id=74 [L]
What happens is that the visitor ends up in an endless loop where he is sent to the TYPO3 site and then to the subdomain and back again.
To get this working, I also need to change the working directory to www.mysite.com (I also have another provider where I can make these changes using a cpanel, and that site runs perfectly). I have been looking everywhere and have tried almost anything, but I simply do not have enough knowledge to change the working directory.
So what code should I use to change the working directory?
Use RewriteCond to not follow this rule for index.php.
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{http_host} ^m.mysite.com [NC]
# Failing the index.php check, the usual test is to look for any
# existing file
# EDIT: Changed URI to start with / - should work per comments
RewriteCond %{REQUEST_URI} !^/index.php
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://m.mysite.com/index.php?id=74 [L]
I followed this tutorial to manage subdomains for a MODx Revo 2.1.3 installation. The idea is that the htaccess file in the web root folder redirects calls for subdomain.mydomain.com to a folder in the web root directory by the same name as the subdomain, ie /home/mydomain/www/subdomain. Subdomain contains the MODx files to run the page, as well as another htaccess to point all further requests back to the root folder.
The better part of it works; I can view the homepage of the site (which means MODx is doing its part), but none of the links to the css, js, images, etc work, and it seems like the Wayfinder and getResources packages are failing to output. The links that are being used for the images+css+js are /subdomain/assets...etc; I need the links to point directly to the /assets folder. It's like the root .htaccess works to redirect the request to the subdomain folder, but the .htaccess in the folder doesn't point anything back up to the root for the remaining requests.
Here's my root folder htaccess, the 2nd part taken from the tutorial:
RewriteEngine On
RewriteBase /
# The Multiple subdomains part
#REDIRECT SUBDOMAIN TO SUBDIRECTORY OF SAME NAME
RewriteCond %{ENV:REDIRECT_SUBDOMAIN} =""
RewriteCond %{HTTP_HOST} ([a-z0-9][-a-z0-9]+)\.mydomain\.com\.?(:80)?$ [NC]
RewriteCond %{DOCUMENT_ROOT}/%1 -d
RewriteRule ^(.*) %1/$1 [E=SUBDOMAIN:%1,L]
RewriteRule ^ - [E=SUBDOMAIN:%{ENV:REDIRECT_SUBDOMAIN},L]
and the subdomain folder htaccess is simply:
RewriteEngine On
RewriteBase /
I know the site works; I can access it using a subdomain that hasn't been processed like the tutorial yet. So it's all there, I just need to sort out the link requests. Can anyone help?
Thanks to some assistance, I managed to find the solution to this issue.
# The Multiple subdomains part
#REDIRECT SUBDOMAIN TO SUBDIRECTORY OF SAME NAME
RewriteCond %{ENV:REDIRECT_SUBDOMAIN} =""
RewriteCond %{HTTP_HOST} ([a-z0-9][-a-z0-9]+)\.spitfireresources\.com\.?(:80)?$ [NC]
RewriteCond %{DOCUMENT_ROOT}/%1 -d
#RewriteCond %{REQUEST_FILENAME} !^/js
#RewriteCond %{REQUEST_FILENAME} !^/css
#RewriteCond %{REQUEST_URI} !^/assets
RewriteCond %{REQUEST_URI} !^/
RewriteRule ^(.*) %1/$1 [E=SUBDOMAIN:%1,L]
RewriteRule ^ - [E=SUBDOMAIN:%{ENV:REDIRECT_SUBDOMAIN},L]
The key line is RewriteCond %{REQUEST_URI} !^/. Once that was in place everything becomes accessible. Thanks to everyone who commented.