We are working on a Magento site that has several different stores. We are working on rewriting the url so when you are in a specific store, the store name is added to the url. We have tried a couple of different things. First by turning on "Add Store Code to Urls" in System>Configuration>Web. This causes one of the store names to be added to the url twice and the rest of the stores the base store name is added. Our second idea was to add:
SetEnvIf Request_URI ^\/site_wow\/ MAGE_RUN_CODE=site_wow
SetEnvIf Request_URI ^\/site_ahepa\/ MAGE_RUN_CODE=site_ahepa
SetEnvIf Request_URI ^\/site_ita\/ MAGE_RUN_CODE=site_ita
SetEnvIf Request_URI ^\/site_deca\/ MAGE_RUN_CODE=site_deca
to the .htaccess file in the public_html folder on the site. This works for the ahepa store but none of the others. If I change the other stores to MAGE_RUN_CODE=site_ahepa, it adds the site_ahepa to the url.
I found a similar question here: Magento site switching .htaccess but am not having any luck fixing the problem. If there is anyone who could send me in the right direction I would greatly appreciate it.
Ok, here is what I got to work. I have the .htaccess file as it is above. In System>Configuration>Web, I have Add Store Code to Urls set to YES and Use Web Server Rewrites set to NO. The url rewrite for the ahepa store is different that the other stores but all of the links redirect to the correct stores and the products are showing up where they are supposed to so I am not going to mess with it anymore.
Related
I've just setup a new subdomain 'preview', ie preview.example.com and I am setting up a replicate of the codebase of a live website (from the www. subdomain) so that I can have a duplicate environment for testing and showing my client recent changes.
I want to save myself having to copy over all the images to the preview and so the normal location under which images are saved in a WordPress site /wp-content/uploads/ is empty. I wanted to ues a simple htaccess rule to get these instead from the live subdomain where the image at the same path will exist. In other words, a request for
https://preview.example.com/wp-content/uploads/2021/01/test.jpg
would be redirected to the following where the image exists..
https://www.example.com/wp-content/uploads/2021/01/test.jpg
I've tried to set this up with the simplest of htaccess redirect rules but it just seems to be ignored and I've no idea why. Any idea how I can troubleshoot this?
RedirectMatch 301 /wp-content/uploads/(.*) http://www.example.com/wp-content/uploads/$1
Converting my comment to answer so that solution is easy to find for future visitors.
Scenario is that both subdomain and main domains are on same host but their DocumentRoot are set to different paths. OP wants to serve lot of images from subdomain but doesn't to do bulk copy.
Suggested approach without tinkering with .htaccess is to create a symbolic link of wp-content/uploads/. Only option suggested to use in .htaccess is:
Options +FollowSymLinks
Which allows use of symbolic links for serving web requests.
After I have upgraded my site I see that once I go live with new version some parts of the website URLs will not be redirected for gallery, blogs and files because of new structure. And there is no way fixing it within the CMS. So my goal is to use NGINX redirects.
I wonder do any of you know any NGINX rewrite tricks to make such redirects possible?
website.com/forums/blogs/ into website.com/blogs/
website.com/forums/gallery/ into website.com/gallery/
website.com/forums/files/ into website.com/files/
I actually need the part forums dropped from the URL only and ONLY when the address is going for forums+blogs/gallery/files. Don't want to loose that google traffic.
So for example
website.com/forums/blogs/entry123/my-dog/ is redirected to
website.com/blogs/entry123/my-dog/
BUT
website.com/forums/topic/my-dog/
is left alone and working just like before because the following subfolder is neither blogs or gallery or files.
I needed that once on Apache and this one worked but on Nginx I have no idea.
RewriteRule ^forums/(blogs|gallery|files)/(.*)$ /$1/$2 [L,R=301]
You can try something like
rewrite ^/forums/(blogs|gallery|files)/(.*)$ /$1/$2;
Please note that rewrite directive accepts some flags wich meaning depends on where is it placed (is it inside a server or location block). Detailed documentation is here.
I just rebuilt my site to be responsive with Gantry 5 and Joomla. built in inmotion hosting server. moved it into a sub domain on my real sites server, www.umiultrasound.com/new. when i try to access the site to test it redirects to www.umiultrasound.com.
I have discussed this with my host, they say i have a wildcard redirect- i don't. they say to check my .htaccess file. i did but i do not see where i am redirecting / or www.mysite.com to itself.
they then recommended that i read one of your forum results. the one they sent didn't apply to me. hoping you can help
Check for any RewriteBase command in .htaccess. You could also temporarily copy the standard htaccess.txt over .htaccess to see if this makes any difference (backup .htaccess to .htaccess.old or similar first).
Also check your configuration.php file to see if the live_site parameter has been set.
I have different store views in my magento shop for different languages. I can access them through
www.serverdomain.from.my.hoster.tld/langkey/
The langkeys are the codes of the different store views and I enabled "add store code to urls".
Now, I want to use my following registered domains without editing index.php
www.myshopsite.langkey
for example:
www.myshopsite.de
www.myshopsite.en
www.myshopsite.com
For that I tried to set MAGE_RUN_CODE and MAGE_RUN_TYPE via htaccess till I realized that they are used to get different stores and not different store views.
Since I configured the base URL for my german store view I can access it via
www.myshopsite.de/de/
Now I am trying to internally redirect from www.myshopsite.de/ to www.myshopsite.de/de/ to remove the trailing store view code.
Thats my try which ended in a redirect to www.myshopsite.de/en/ and an internal server error
RewriteEngine on
RewriteRule ^$ de/$1 [L]
RewriteRule ^(.*) de/$1 [L]
I am sorry if my fault is obvious.
You can try this at the bottom of your .htaccess file located in your Magento root directory.
SetEnvIf Host www\.myshopsite.\.$ MAGE_RUN_CODE=$1
The MAGE_RUN_CODE variable is for the Magento Store View. You essentially set it to the store view code set under System > Manage Stores > Store View
I've done quite a bit of these configurations so I know that sometimes your server environment setup (apache etc) may differ, and using SetEnvIf in .htaccess may not work. If that is the case, you may be better off inserting a bit of code into the index.php that achieves the results you are looking for.
Yes, it's modifying a core file, however given this scenario is might be more stable to have PHP handle the store variable mapping rather than apache.
I'm looking for some help with my .htaccess file.
In short, I have a bunch of content up in the subdirectory www.myserver.com/forum/ (this directory is not my choice and cannot be changed), which includes both a forum (myserver.com/forum/forum) and a wiki (myserver.com/forum/wiki) and this is abviously not an ideal layout. I do not own myserver.com and there is content there that is not mine, though I have full access to the entire server.
I also have a domain name www.mydomain.com, which I want to redirect and mask such that if a user goes to mydomain.com/<something> they will be shown the content from myserver.com/forum/<something> while still being shown mydomain.com/<something> in the address bar.
One other thing I'd like to see, although it isn't vital, would by for a 404 generated by someone typing in mydomain.com/somethingThatDoesNotExist should redirect to mydomain.com/404.php instead of myserver.com's default 404.
I've tried a number of different approaches and searched extensively for the past day or so online - I'm sure that the answer is even here on SO somewhere, but all of the guides/examples I've tried have not worked and I feel like I'm going in circles.
Many thanks in advance.
EDIT: And I do know for sure that .htaceess is enabled.
if a user goes to mydomain.com/ they will be shown the
content from myserver.com/forum/ while still being shown
mydomain.com/ in the address bar.
First thing you need to understand that this is ONLY possible if mod_proxy is enabled on the Apache server of mydomain.com.
Once you've enabled mod_proxy, mod_rewrite and .htaccess through httpd.conf on mydomain.com, put this code in its .htaccess under DOCUMENT_ROOT directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteRule ^(.*)$ http://myserver.com/$1 [L,P]
I will have to think little more about your 404 requirement, but if you get this working I am sure we can find a workaround for that as well.
You could do some proxying with PHP or whatever other language they allow..
Take a look at file_get_contents behind a proxy?