Replace URLs in Typo3 DB - mysql

So I have a Site created with Typo3. I also have a domain which is linked to the folder of the Typo3 Installation. www.example.org
I created a Subdomain and linked it to the same folder and used the Main Domain for something else.
But now everything on the Subdomain still has the URL Structure of the main site so when I open up sub.example.org all the Links and Images still have the URL from www.example.org/...
I exported the Database and replaced every URL with notepad++ and imported it again. But that didnt change anything. What do I do wrong?

There are two (three with realurl) places where you need to look if changing the domain of a TYPO3 site, if everything is done by the book and noone hardcoded the domain all over the place or something.
Usually you do not need to work in the database directly.
After doing the changes, make sure to clear the caches (install tool in 6.2+, "all caches" in earlier versions).
First:
There are two TypoScript settings that influence the generated URL: config.baseURL and config.absRefPrefix.
The recommended way to use those is to not set config.baseURL (would result in a <base> tag in the HTML <head>), and set config.absRefPrefix to the subpath where TYPO3 is, relative to the document root. If TYPO3 lies directly in the document root, set it to /.
Second:
In the database, there are "Domain Records". They are usually located on the root page of a site. Change those to the new domain.
Third (with realurl only):
Check the realurl configuration file, usually located in typo3conf/realurl_conf.php. Depending on your setup, the old domain name is used there and needs to be changed.

Related

How to not load Index.html?

When a website doesn't have an index.html file, the navigator displays an auto generated page right ?
Here is an example of what I mean.
This page is very handful to explore a website, but sadly it is only displayed when there is no index.html page.
Is it possible to access such a page on a website, even though index.html exists in the folder ?
I'm using Opera, but I have tried other navigators and none of the common ones seems to do what I want ^^
Thanks for reading
This is not an auto generated page. It is directory browsing of server which can be enabled/disabled through server control panel (or using .htaccess in linux servers).
When you have default document (like index.html) in a folder, the server servs the default document instead of directory browsing. So if you want to let directory browsing when you have index.html, you have to clear the index.hmtl from the list of default documents. This can be done using IIS settings (if you have access to server) or through hosting control panel in website settings (in shared hostings) (or by direct editing of web.config or .htaccess)
the navigator displays an auto generated page
No. This has nothing to do with the browser. The browser displays whatever the server returns. Nothing more, nothing less.
What you're seeing on that link is from the Apache web server. That web server is configured to (and can be configured not to) return a generated directory listing when no default response can be determined.
The "default response" might be index.html, or default.html, or literally anything that the web server is configured to look for by default. (Those are just, well, the common defaults.)
In many modern web applications the concept of a "page" doesn't even really mean the same thing, because things like MVC frameworks don't just browse directories for .html files but instead examine requested routes and generate responses from code.
Is it possible to access such a page on a website, eventho index.html exist in the folder ?
No. Because that "page" doesn't exist. The web server returned that to you because it was configured to. If it's not configured to then that data doesn't exist.

Database Name not being included in the HREF of imported files in File Resource

I imported some HTML, JS and image files into Resources->Files of my database.
In the index file, I have:
<base href = "/client/hd">
<img src= "/client/hd/images/imagefile.png">
But upon checking the image source, it's accessing the URL below:
http://his90/client/hd/images/imagefile.png excluding the location of database and database name (ex. /fi20/fi20test.nsf)
It should be http://his90/fi20/fi20test.nsf/client/hd/images/imagefile.png
May I ask for a solution for this? HTML files are just imported in the Resource, no forms or views were created.
That is because you start the link URL with a /. That will start at te root of the web server. If you remove it, the link URL will start from your current location, and (assuming that the index file has the URL http://his90/fi20/fi20test.nsf/index.html) you should get the correct link URL.
You can also create a substitution rule for the internet site (using Domino Administrator, under Configuration, Web, Internet Sites). You then substitute / with /fi20/fi20test.nsf/ and it should also work.
Talk to your administrator about which is the proper way in your specific case.
Also, assuming you add the image as an image resource called imagefile.png, the URL should be just http://his90/fi20/fi20test.nsf/imagefile.png, no file structure.
What I sometimes do is to create web substitution rules for /images/, /pages/ and /agents/ to all point to the .nsf file itself. Then in the HTML code (and Javascript) I can reference the different resources with /images/imagefile.png or /agents/getUserList.json, etc. Makes the code much easier to read and understand.

html post from subfolder - post url includes top level site in URL

I have a site:
example.com/index.html
There is a subfolder (subsite):
example.com/subsite/different_index.html
different_index.html contains a form:
<FORM action="different_index.html?action=edit">
However, when the submit input button on this form is clicked, the page attempts to redirect to:
example.com/subsite/subsite/different_index.html
I've tried making the form action the exact url needed:
<FORM action="example.com/subsite/different_index.html?action=edit"> <!-- target self -->
But I still get:
example.com/subsite/subsite/different_index.html
subsite is duplicated within the URL.
Any ideas how to correctly target this form?
The fact that you have a form is actually irrelevant. What you are really asking is about referencing resources and the rules are pretty simple:
If the resource you need is part of the same web site (not talking about folder structure here, talking about domain), you should use relative paths, where:
a. fileName.ext is all you need if the resource is in the same folder as the currently loaded document.
b. folderName/fileName.ext is what you need if the file you need is in a sub-folder of the current folder that the loaded document is in.
c. ../fileName.ext is what to use if the file you need is one directory higher than the current document's folder. The ../ can be repeated if you need to go up more than one level (i.e. ../../fileName.ext).
d. /fileNameext or /folderName/fileName.ext indicates that the file or folder specified should be found starting from the root of the web site, regardless of where the current document is.
If the resource you need is located on another domain, you'd use an Absolute Path (http://something.something/file.ext).
a. DO NOT use absolute paths for local resources! This may work but causes the domain name to have to be resolved again, resulting in a longer load time.
WARNING: Different servers have different configurations and requirements that may affect whether these reference rules work or not. For example, GoDaddy web hosting provides an "httpDocs" folder at the root of a web site. You don't have to use it, but that's where their servers expect the site's content to be placed. Not following those rules result in relative paths not working. Additionally, many servers are hosted on operating systems the have case-sensitive file systems, so always refer to files and folders in the same case that is actually used. Again, not doing this may work for you locally, while you develop (because you haven't moved the files to the remote server yet), but don't let that lull you into thinking that case doesn't matter.

How can I simply expose local .html files via web browser using an application server (Glassfish)?

Lets say I have a directory of .html files, accessible by the app server, and I want to display to users so they can access them with their browser:
/import/tps-reports/index.html
/import/tps-reports/report1.html
/import/tps-reports/report2.html
Is there a way I can expose the tps-reports directory to do this so that a user can access them via:
http://www.example.com/tps-reports/index.html
http://www.example.com/tps-reports/report1.html
Also, keep in mind that index.html may reference the other pages:
Report 1
So those links need to work as well.
Here is a possible answer:
http://docs.oracle.com/cd/E19776-01/820-4496/geqpl/index.html
You can set up an alternate doc root so that certain URI patterns point to different paths.
The examples are only really showing relative paths though...I wonder if its "ok" to use this to reference local file systems.

Do I need to specify a webpage's url?

I've uploaded several files to my server and it's really quite baffling. The home page is saved as index.html, and when I type in the URL of said page it miraculously, and quite successfully shows the right page. What about my other pages? I have linked to them from the home page with the following code:
About Us
How does my html file, presumably called about.html, supposed to know that its URL is "http://www.example.com/about/"? I am dubbing this "The Unanswered Question" because I have looked at numerous examples of metadata and there is nothing about specifying the URL of a page.
It depends on what type of server you are running.
Static web servers
If it is the simplest kind of static file server with no URL aliasing or rewriting then URLs will map directly to files:
If your "web root" was /home/youruser/www/, then that means:
http://www.example.com -> /home/youruser/www/
And any paths (everything after the domain name) translate directly to paths under that web root:
http://www.example.com/about.html -> /home/youruser/www/about.html
Usually web servers will look automatically for an "index.html" file if no file is specified (i.e. the URL ends in a /):
http://www.example.com/ -> /home/youruser/www/index.html
http://www.example.com/about/ -> /home/youruser/www/about/index.html
In Apache, the filename searched for is configurable with the DirectoryIndex directive:
DirectoryIndex index.html index.txt /cgi-bin/index.pl
That means that every request to a path that ends in a / (and to add yet another rule, under some common settings it will automatically append a / if the path is the name of a directory, for example 'about'):
http://www.example.com/ -> /home/youruser/www/index.html
-> or /home/youruser/www/index.txt
-> or /home/youruser/www/cgi-bin/index.pl
Web servers with path interpretation
There are too many different types of servers which perform this functionality to list them all, but the basic idea is that a request to the server is captured by a program and then the program decides what to output based on the path.
For example, a program might perform different routes for basic matching rules:
*.(gif|jpg|css|js) -> look for and return the file from /home/user/static
blog/* -> send to a "blog" program to generate the resulting page
using a combination of templates and database resources
Examples include:
Python
Java Servlets
Apache mod_rewrites (used by Wordpress, etc.)
Links in HTML pages
Finally, the links in the HTML pages just change the URL of the location bar. The behavior of an HTML link is the same regardless of what exists on the server. And the server, in turn, only responds to HTTP requests and only produces resources (HTML, images, CSS, JavaScript, etc.), which your browser consumes. The server only serves those resources and does not have any special behavioral link with them.
Absolute URLs are those that start with a scheme (such as http: as you have done). The whole content of the location bar will be replaced with this when the user clicks the link.
Domain relative URLs are those that start with a forward slash (/). Everything after the domain name will be replaced with the contents of this link.
Relative URLs are everything else. Everything after the last directory (/) in the URL will be replaced with the contents of this link.
Examples:
My page on "mydomain.com" can link to your site using the Example.com about just as you have done.
If I change my links to about then it will link to mydomain.com instead.
An answer your question
How does my html file, presumably called about.html, supposed to know that its URL is "http://www.example.com/about/"?
First, the file itself has no idea what its URL is. Unless:
the HTML was dynamically generated using a program. Most server-side languages provide a way to get this.
after the page is served, client-side scripts can also detect the current URL
Second, if the URL is /about and the file is actually about.html then you probably have some kind of rewriting going on. Remember that paths, in their simplest, are literal translations and /about is not the same as about.html.
Just use /about.html to link to the page
Theoretically, it's better for URLs in your documents to be relative, so that you don't have to change them in the event you change the domain or the files location.
For example, if you move it from localhost to your hosted server.
In your example, instead of www.example.com/about.html use /about.html.
Given the link above you would need a about page named index.html located in a directory named about for your example to work. That is however not common practice.
I'm a bit confused, but here is some information. Any file named "index" is the default display page for any directory(folder) when trying to view that directory.
All files in a folder are always relative to that directory. So if your link is in a file, within a different directory, then you must type in that directory along with the file. If it is the same directory, then there is no need to type in that directory, just the file name.
about.html doesn't know what it's URL is, its the index.html file that calls your about.html file.
When you're in any given directory, linking to other pages within that directory is done via a simple relative link:
About Us
Moving up a directory, assuming you're in a sub folder (users) perhaps you can use the .. operator to navigate up one directory:
About Us
In your case your about page is in the same directory as the page you're linking from so it just goes to the right page.
Additionally (and I think this may be what you're asking) if you have:
about.html
about.php
about.phtml
about.jpg
for example, and you visit http://www.yoursite.com/about it will automatically bring up the html page and the other pages should be referenced explicitly somewhere if you want them to be used.