When i write my website nonwww domain (domain.com) in Microsoft Edge i get an HTTP 400 error. The problem happend when i write this inside textarea "Search or enter new website". This is default in Edge and everybody writes in.
I dont understand what could be causing this problem? Every browser redirects normally.
Should i do some customization in htaccess file?
I found this solution but it seems not to work and i dont know if i am going in the right direction:
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} Edge
RewriteRule .* http://www.example.com/? [NC,L]
Because of many reasons, partly as a legacy from a time when users are less internet-savy, most browsers will automatically adds www. (or .com) when:
You enter a domain without the protocol part (http://), and
The domain cannot be found.
It seems that Edge 11 doesn't do that.
If that is the case, your direction is correct.
But you must do it for and only for the virtual host that serve the non-www domain.
If your server does not know it should handle non-www domain, the request won't even reach your rewrites.
By the way, you may want to remove the Edge condition and simply redirect all browsers, to save them from guessing.
Related
I have a website hosted on 000webhost and a paid domain was purchased from 1and1. 1and1 offers URL redirecting with HTTP or frame redirect, but I have opted to point the paid domain to 000webhosts name servers.
Currently this works to the point that when I type the paid domain in (www.paiddomain.co.uk), it points me to the correct website (www.freedomain.com). Once on this page any page that is clicked shows up in the address bar as www.freedomain.com/link when what I want is for it to show up as www.paiddomain.com/link.
What's the best way of doing this?
Terminology
origin server - the server that provides the original content
proxy server - the server that sits in the middle between the client and the origin server
In your case the origin server is freedomain.com. It sounds like you opted out of a proxy server and just have the DNS pointing to the origin server.
Reason
The first page loads fine because it is accessible by two domains. However the HTML content that was delivered has absolute links to the origin server. Therefor when the client clicks on it they are taken directly to the origin server.
Without a proxy server you have two choices
Get the origin server to generate absolute links to the domain you want.
Get the origin server to generate relative links.
This depends on how your pages are generated (static html, drupal, wordpress, custom app). But the net effect is that your links will be generated like this:
absolute URL
or like this:
relative URL
If your site uses cookies you will also need to figure generate them for the correct domain.
For systems that generate an absolute URL they will usually have a variable that stores the "site url", "base url", or similar either in their configuration or in the database.
With a proxy server
You can ask your proxy server to translate links (and cookies, etc) from freedomain.com to paiddomain.com. This depends on the proxy server, in apache you would use ProxyPassReverse.
1and1 is apparently not willing to be your proxy server:
http://faq.1and1.com/domains/domain_admin/domain_dest/3.html
They are willing to provide a frame (poor bookmarkability), or HTTP redirect (change the URL).
With a RedirectRule in the .htaccess file:
Example - Redirect from www.freedomain.com/link to www.paiddomain.com/link:
RewriteEngine On
RewriteCond %{HTTP_HOST} !www.freedomain.com/link$ [NC]
RewriteRule ^(.*)$ http://www.paiddomain.com/link/$1 [L,R=301]
More info
I was running in to this same problem when using the frame redirect offered by 1and1. My page had absolute URLs to an external site and when clicked they would load a blank page with my 1and1 domain in the title bar.
Chrome out put this error:
'absolute link to external site' in a frame because it set 'X-Frame-Options' to 'sameorigin'.
Turns out when I clicked the links the browser was trying to open them in the frame 1and1 added to my page. The solution was to add the target attribute to my links and set it to _top. This causes the links to be opened fully in the current window/tab and ignore the frame.
I have a small system (Coldfusion8, MySQL 5.0.88), which allows users to skin the main website depending on their prefrences.
This works all well, except for the URL still being ugly like so:
www.my_site.com/index.cfm?user=123456789
I now want users to have their own URL displayed and have read into vhost (I'm running Apache) on how to do this. I'm changing skins depending on the id provided in the URL. If I now setup my system to display:
wwww.users_selected_url.com
versus the above, I will have no way to check for the URL ID. I'm using this ID check a fair bit throughout the application to customize the page layout when rendering the page with Coldfusion.
Question:
When will the URL be reformatted? Will the page being loaded still be requested with the original URL, so Coldfusion can do it's stuff and only the page displayed to the user will be with his customized URL? How about if I also use URL-rewriting?
Thanks for some info!
You need to have a vhost setup to accept requests for the wwww.users_selected_url.com host, and the DNS needs to point to your server. In the vhost config, you can use the rewrite module to change the URL to /index.cfm?user=123456789, and this rewriting happens before the URI is handed off to cold fusion. You need to add this to your vhost config:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?users_selected_url.com$ [NC]
RewriteRule ^/$ http://www.my_site.com/index.cfm?user=123456789 [L,P]
This uses mod_proxy to proxy the request to http://www.my_site.com/index.cfm?user=123456789 when someone goes to http://www.users_selected_url.com/ in their browser.
I have over 90 urls set out in the following format:
http://www.mysite.com/folder1/folder2/page.html
Each of these URLs will be printed on paper for a user to input into their address bar. The problem at the moment is they are too long and therefore I need make these URLs as short as possible.
However, what would be the best method for doing so?
Would sub folders be the best thing here, such as "keyword.mysite.com"?
I don't want to use a url shortening service as they still need to be related to my domain name. Additional domain names forwarding on to the pages are also out of the question due to the quantity of urls.
Richard
Without knowing what technology you are working with (apache/php, asp.net, JSP, etc) all I can suggest is investigating Url Rewriting. Here is a codeproject example of a rewriter for ASP.Net.
There's a handful of mechanisms that come to mind quickly. One is to host your own url-shortening service for your own domain: http://docs.example.com/xsdf and so forth. Writing one for your own users shouldn't be too much work, especially since you could even write a quick script to submit all the URLs for shortening and replace them all without ever making a pretty interface for a human.
If you want something even cheaper, but more work on the part of your server admins, you could use the standard 'rewriting' services in web servers:
Apache mod_rewrite guide
RewriteRule ^/xsdf$ folder1/folder2/page.html [R]
RewriteRule ^/qwer$ folder2/folder3/page.html [R]
RewriteRule ^/polz$ folder7/folder6/page.html [R]
nginx HttpRewriteModule.
rewrite ^/xsdf$ folder1/folder2/page.html redirect;
rewrite ^/qwer$ folder2/folder3/page.html redirect;
rewrite ^/polz$ folder7/folder6/page.html redirect;
Updating these rewrite rules involves editing the server config files, or dropping new ones in place. The other mechanism would be outside the range of the web server itself, so it might be easier or harder for long-term maintenance depending upon which your team would rather work with in the future.
The rails codebase that I'm working on supports two web applications, and we use apache to rewrite the url intelligently when a user comes to our domain, so for example if you approach our site from
app_name.domain_name.com
it is rewritten to
app_name.domain_name.com/app_name
and our nested routes are called. This is a recent change to our app however, and (obviously) some bookmarks aren't forwarding properly. What I'd like to do is modify our routes (or maybe add a small piece of middleware) which attempts tot rewrite to the correct url rather than displaying a 404 message.
That is to say, if a customer tries to view
app_name.domain_name.com/controller/action
our nested routes miss the call, and instead of 404ing, the app rewrites the request to:
app_name.domain_name.com/app_name/controller/action
Can I do this with either a clever route, or with some middleware? If not, can this be done with apache rewrites?
Thanks
Try this
RewriteCond %{HTTP_HOST} ^web_app.benchmark.company.net$ [NC]
RewriteRule ^/?(.*) /web_app/$1 [L,R=permanent]
(Note that I have not tested this)
I recommend you read the Apache rewrite guide.
The rails app I have allows users to manage holiday homes. Each property has it's own
"website/homepage" within my app and a user can tweak the content, it works well,
quite pleased so far. Typical rails approach to the resources so the URLs to a particular property look like this for the "homepage" of a particular property.
localhost:3000/properties/1/
then
localhost:3000/properties/1/full_details
localhost:3000/properties/1/price_list
etc
Requirement is to map a domain name e.g. www.chalet-yeti.com and have it resolve (rewrite?) to localhost:3000/properties/1/
like so also...
www.chalet-yeti.com/full_details -> localhost:3000/properties/1/full_details
The next user adds a property and I register a new name on their behalf and I'd like to do this of course..
www.apartment-marie.com -> localhost:3000/properties/2/
Is this possible/advisable/doable in the same rails app? So far solutions have ranged from "why would you do that" to variations on "use mod_proxy / mod_rewrite / virtual_host config". In case it matters the app runs under apache and passenger on my server.
I don't want to pre-empt an answer but most people so far seem to point to apache configuration and most say what I'm attempting is not impossible / inadvisable. Really hope someone could at least point me in the right direction as I've been head scratching all morning. Out of my comfort zone here and I'm hoping I can launch my app and haven't spent six weeks building a white elephant! Unless I can do this URL thing, it's dead!
http://37signals.com/svn/posts/1512-how-to-do-basecamp-style-subdomains-in-rails
This is what you want. Don't mess with apache for that. It doesn't scale to hundreds of domains and it's prone to breakage.
Within Rails, you should think of the requests coming just to a URI, without a host name section. That is, instead of localhost:3000/properties/1/full_details you need to think of /properties/1/full_details. The localhost:3000 part is just to get the request to Mongrel during the development process.
So what you really want is to take the request as it is received by the HTTPd (Apache, in your case) and extract some information to construct the request which is given to Rails.
mod_rewrite, which is an Apache module, is the sane way to do this.
You need to ensure that the same virtual host which runs your Rails application accepts requests for all the domain names you're using.
Then you can use mod_rewrite to do something like this:
RewriteCond %{HTTP_HOST} ^(www.)?chalet-yeti\.com$
RewriteRule ^(.*)$ /properties/1/$1 [L]
This will take every request to the host chalet-yeti.com (or www.chalet-yeti.com) and hand them to Rails as "/properties/1/$1" (where the $1 is any additional path, like full_details).
You'll need a block like that for each of your domains, but that's just two lines in your Apache configuration. Unless you're doing hundreds of domains, it should be tolerable, right?