Magento URl Handling? - .htaccess

I have created the new magneto site and importing the data from the old site but I have the problem with the URLs.
Old site URL starts from wwww.sitename.com
but in my new site it starts from sitename.com without www.
Now I am trying to add WWW in my magento site or remove the WWW from the old site through .htaccess file
but the problem is when I change the magento site bse URL to www.sitename.com it is giving server not found error
I have also used the htacess rule to remove the WWW from the old links?
any hint regarding this issue ?

1 ) System > Configuration > Web > Unsecure and Secure
Check correct url are setup or not. (www)
2) .htaccess changes :
RewriteCond %{HTTP_HOST} ^yoursitename.com$
RewriteRule (.*) http://www.yoursitename.com$1 [R=301]

If you have access to the database, the table you could edit is core_config_data and the values you need to change are in the path column. Change the web/unsecure/base_url and web/secure/base_url to match the new domain name by altering the value column for both records

Related

Redirect An Unknown Source Domain To Subfolder Using .htaccess

I am interested in offering my users a "white label" service, wherein they will set up a CNAME record that points to my server.
For example, I would like client.theirdomain.com to actually redirect to https://example.com/client/, but keep the URL still as client.theirdomain.com (and, further, if they click a link that is actually https://example.com/client/something.html, it would appear to the user as client.theirdomain.com/something.html.
I attempted to do this in my .htaccess with the following;
RewriteCond %{HTTP_HOST} ^client\.(.*)\.(.*)$ [NC]
RewriteRule ^$ /client [NC,L]
For posterity, I also have a valid subdomain created (client.example.com) that directs to the root of my website, as well as a CNAME record created on a client's server (which points client.theirdomain.com to client.example.com).
When I attempt to use the above settings, however, I receive an error that there were too many redirects.
Thanks!

Redirect all subdomains to subdomain at different domain

Hi I need to redirect all subdomains in a domain to the same subdomain but at a different domain. The best way im guessing is through a htaccess file but im not sure how the file would be.
Example:
sd1.example.net ---> sd1.example.com
sd2.example.net ---> sd2.example.com
sd3.example.net ---> sd3.example.com
But I need this to be done for all of the subdomains in example.net. Thanks.
If you have an Apache server running on example.net and the requests for all the subdomains look in the same parent directory you can do something like the following:
RewriteEngine On
### Find the subdomain part (it will be available in %1)
### Use one of the RewriteCond-s and delete the other one
# Only redirect subdomains, not plain example.net
RewriteCond %{HTTP_HOST} ^(.*)\.example\.net$
## Redirect both subdomains and plain example.net (uncomment to enable)
#RewriteCond %{HTTP_HOST} ^(.*\.)?example\.net$
# Find the path requested (it will be available in $0)
# This rule does not attempt to match the domain, only the path
# Redirect subdomain and path to example.com
RewriteRule ^.*$ http://%1.example.com/$0 [L]
I haven't tested this so it might be missing query strings, etc. It will also undesirably redirect https:// to http://. As long as you have a single .htaccess file that can affect all your subdomains this should work, or at least be a very good starting point. Check out Apache's mod_rewrite documentation for more information about how this works.
EDIT
Having recently wanted to do exactly this myself recently, I have worked out a short .htaccess file that does the trick:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(.*\.)?olddomain\.com$
RewriteRule ^(.*?/)?public_html/(.*)?$ "http\:\/\/%1newdomain\.org\/$2" [R=301,NE,L]
It assumes the following file structure:
.htaccess
public_html/
+-content
lots/
+-public_html/
| +-content
of/
+-public_html/
| +-content
subdomains/
+-public_html/
+-content
My main site (newdomain.org) is in /public_html/. I have a number of subdomains, e.g. subdomains.newdomain.org which is in /subdomains/public_html/. This keeps all the files of each my subdomains completely separate from each other and my main site. (My hosting service recommends /public_html/, /public_html/subdomains/ but that means each subdomain is also accessible at newdomain.org/subdomains/ which is not what I want). The only restriction this gives me is that I can never have a subdomain called public_html, which I think you'll agree is perfectly acceptable.
The flags on the rule are as follows:
R=301 - Redirect with a 301 Moved Permanently code. You can change the code if you don't need a permanent redirect, e.g. 302.
NE - No Encoding - Don't URI encode the new address, i.e. keep % as %, not %25
L - Last - Stop processing rules
Note that the .htaccess file must be in the root directory of your web server, not in the directories with your content files. This is because the rewrite rule works at the file system level, not the URL address level.
An address:
any.subdomain.olddomain.com/any/address.html?any=query&you=like
is changed to:
any.subdomain.newdomain.org/any/address.html?any=query&you=like

Use of page to redirect

I need to set up a page to redirect from our old server to our new server, advising people of the new URL and to change their bookmarks. I know how to use the refresh meta tag in HTML to do this.
But I also want to set it up so that they would see the redirect page no matter what page they have navigated to on the old server. I see several solutions using 301 redirect.
How would I do both? We're running an Apache server on Debian server.
You need to use Apache an RewriteRule using mod_rewrite. This can be placed in an .htaccess file on your server’s root, or it can be placed directly into your Apache config file.
So let’s say your new redirect page—where you explain the site has moved and have set a refresh meta tag—is called redirect.php, then this is the Apache RewriteRule that should work for your needs.
RewriteEngine on
RewriteRule ^(.*)$ /redirect.php [L,R=301]
This will grab any URL on the site this RewriteRule is placed on & redirect them to /redirect.php. That /redirect.php can also be a full URL such as http://mysite.com/redirect.php or anything else.

TYPO3 multidomains for developing

I use a developer domain (domain.com.dev) for my local installation. For that I created three domain records for one domain:
domain.com -> redirect to http://www.domain.com
www.domain.com
domain.com.dev
But to get domain.com.dev working I have to deactivate the first two one. Will be there an other solution to do that with constants or pageTSconfig?
edited:
Using now htaccess-redirect for non www.
# Redirect non-www to www and ignore dev subdomain.
RewriteCond %{HTTP_HOST} !(www\.|dev\.).* [NC]
RewriteRule .* http://www.%{HTTP_HOST}/%{REQUEST_URI} [L]
Above I forgot another subdomain, so the domain records now as followed:
First tree:
www.domain.com
dev.domain.com
Second tree:
sub.domain.com
dev.sub.domain.com
But if I call now dev.domain.com the links are parsed as www.domain.com. Before I used baseURL. Than I read somwhere, I can't remember where, that baseURL is outdated.
But if I don't use baseURL this trick will not work. And with sub.domain.com it will not work anyway.
edited II
I' have now following two domain records for the domain sub.domain.com:
sub.domain.com
dev.sub.domain.com
If only one is activated, the internal links will be like href="home.html", if the second is activated they are href="http://sub.domain.com/home.html". But I'm currently on the domain dev.sub.domain.com.
Cause I have more domains in one installation I need these records. But how can I get rid of this prefixed URLs?
If TYPO3 prepends the domain to the links, baseURL will be useless...
In my experience it is not a good idea to structure it that way. It is much easier using dev.domain.com for your dev system and then add this to the hosts file to point to your local system.
The non-www to www redirect should also be made with a .htaccess, not within TYPO3 (performance). To solve the problem with your current structure you could try to remove the domain.com from the list and do then redirect as mentioned. Then the .com.dev should also work.
If I'm understanding correctly you need to setup a baseUrl based on the new domains.
This can be done as follows in TypoScript:
[globalString = ENV:HTTP_HOST=dev.domain.com]
config.baseUrl = http://dev.domain.com/
[globalString = ENV:HTTP_HOST=dev.sub.domain.com]
config.baseUrl = http://dev.sub.domain.com/
[end]
Next, if you use RealUrl or CoolUri, you will also need to create domain-records for these in the Typo3 backend.
Hope this helps :)

how to turn off .HTACCESS rewrite engine off for a file

i have rewrite engine on with a rule to attach www in every url being accessed on my website.
the rule is written in htaccess located in public_html folder. now a problem is i have registered a web application in windows live developer website. as you may know, the windows like applications doesn't accept/allow domains to be verified as www.mydomain.com. they only accept mydomain.com format. so the return url specified in application settings is not delivering data as my verified domain is "mydomain.com" and in return url "www" is being attached due to htaccess rule. so i would like to know if there is any way i can exclude my 1 specific file (not the folder) from all rewrite rules being applied. or is there any way i can verify my domain as www.mydomain.com in windows live applications?
also, is there any way to turn off rewrite rules off for that particular file from PHP?
In your .htaccess rule you can add a condition like this:
RewriteCond %{SCRIPT_FILENAME} !.*myFile.asp$ [NC]
to execute your rewrite rules for everything EXCEPT a file called myFile.asp.

Resources