How does 301 redirect works - url-rewriting

In a typical DNS like GoDaddy and Yahoo, can a 301 redirect do this:
http://mysite.com/abc to http://www.mysite.com/abc
However it seems its not possible; Can the app in the otherdomain know the subfolder?
Update:
What I mean are those DNS redirects, specifically from naked domain to a www domain
Update:
I managed to forward the naked domain from http://mysite.com to http://www.mysite.com/index.html So can I get the requested subfolder through javascript in the index.html?
Or the re-direct loses the subfolder originally requested?

The HTTP 301 response is not handled by DNS. It's a response emitted by a web server to indicate to the browser that the requested resource has been moved permanently to a new location, and it includes a Location: header with the new URL
For example:
HTTP/1.1 301 Moved Permanently
Location: http://www.example.org/index.asp
As you see, the location header can contain contain any valid URL, including a folder name.
Setting this up is server dependent, but Apache's mod_rewrite is certainly capable of rewriting URLs and including the requested folder name in the response.

If you are on a LAMP stack box, you can use .htaccess to redirect. You can redirect any page on site1 to any page on site2.
Redirect 301 /old-page-name http://www.your-domain.com/new-page-name
note, this is not a DNS solution, but I think you might not be looking for a strictly DNS-related answer.

Related

How to fix automatically redirection in netlify page

The url has been refreshed on the netlify page. This will automatically redirect to the api server url, not the netlify url.
In the _redirects file, I changed the http status from 301 to something else, but the results were the same.
Below is my _redirects file.
/* https://api.herokuapp.com/:splat 301
I want to solve the redirection problem quickly. Thanks for reading.
The redirects file must be in thebuild directory. And since it builds as a web page reflecting the build status, it needs to be put into the repository with the built state due to the nature of netlify.

How to rewrite different subdomains as folders within the same site using Netlify

As stated in https://www.netlify.com/blog/2015/10/30/domain-aliasesas-many-as-you-like/ Netlify seems to support this:
Our flexible rewrite rules also means you can even handle different
subdomains as folders within the same site.
But how should this be configured? Seems not documented anywhere.
EDIT
I would like to store files in folder /developer and serve them from http://developer.example.com. So for the user it looks he is browsing http://developer.example.com.
You can define redirect rules to do this by defining them in a _redirects file
To serve content hosted on a subdomain to requests coming to the folder URL:
# proxy the request
/my/folder/path https://subdomain.ofmy.site 200
# redirect the request
/my/folder/path https://subdomain.ofmy.site 302
you can also use wildcards and splats
# proxy the request
/my/folder/path/* https://subdomain.ofmy.site/:splat 200
More detailed docs on defining redirects on Netlify: https://www.netlify.com/docs/redirects/

How to set up 301 redirect of specific pages after moving Magento Community to new domain

I moved my site domain from mysite.me to mysite.com. There are links on the web from other peoples' pages (e.g., blogger) to specific product pages on my old domain (e.g., mysite.me/cat1/prod1).
When I set up the URL Rewrite in Magento Community how do I point a specific URL from my old domain (mysite.me/cat1/prod1) to my new domain (mysite.com/cat1/prod1)?
I'm trying a Custom rewrite. I know the Target Path is relative. Is the Request Path relative too? If request path is relative than I can't do what I want.
I currently have a general 301 redirect for anything going to mysite.me to go to mysite.com. I'm assuming that I need to disable this 301 redirect at the domain level for any URL rewrite to work. However the first question to answer is if I can use URL rewrite for redirecting from one domain to another. I haven't seen a clear answer for this in my research. Just that the Target Path is relative, which makes sense, but nothing redirecting from one domain to another.
Thanks.

404 redirect and keep extensionless URL?

I'm setting up custom 404 redirects (.htaccess is not an option as I'm on IIS6), is there a way to do this and still keep the 'fancy' url in the address bar?
There is not such thing as "404 redirects". 4xx range means error.
In any case -- you can use ISAPI_Rewrite 3 which will bring mod_rewrite support via .htaccess to your IIS6 server. It has Light version which is free.

How to use mod_rewrite to map to a different domain and preserve the original

For example:
www.example.com and subdomain.mydomain.com are on the same server.
When I put example.com in the address bar, I want it to serve the pages from subdomain.mydomain.com, but still show as example.com in the browser. So, if the old URL was:
subdomain.mydomain.com/this/stuff?is_cool=yes
the new url would be
www.example.com/this/stuff?is_cool=yes
You've got a couple options.
Write a proxy on example.com that fetches the content from subdomain.mydomain.com and displays it to the user.
As both sites are on the same server, point example.com's document root to the same spot as subdomain.mydomain.com.
Use a frameset on example.com with a 100% height frame of subdomain.mydomain.com.

Resources