TYPO3 9 - wrong url to homepage - typo3-9.x

In my fluid template I have
{f:uri.page(pageUid:'{uid}')}
It works fine except for main page - it results with url like mydomain.com/.html
Below there is basic Routing configuration:
rootPageId: 1
routeEnhancers:
PageTypeSuffix:
type: PageType
default: .html
index: ''
map:
.html: 0
sitemap.xml: 1533906435`
I would expect link to homepage is just mydomain.com (and not for example mydomain.com/index.html) but I can not make it work in routing in TYPO3 9.

Dont use the .html: 0 line in your code. For me this works
PageTypeSuffix:
type: PageType
default: /
index: ''
map:
/: 0
In the Base Language Part check if base equals /

Related

Page can't be found error and not hitting my app while url contains like .vpf,.html (dot extensions)

If I am using an url like '**' it goes to the error page. But, my application is not getting hit while giving url like '.vpf' or '.vd'. How can I fix it?
What are you using for your web server? IIS?
You need to add Handler Mappings for those file types that you want to serve; note that IIS will have defaults for .htm, .axd, etc, but not other types, like .vpf.
Try requesting those files directly in the browser (not via javascript) and running Fiddler at the same time, and you should get more information about what is and isn't happening.
added route with constraints in startup.cs
routes.MapRoute(
name: "xxx",
template: "{xx}/{yy}/{*zz}",
defaults: new { controller = "Home", action = "Index" },
constraints: new { xx= #"^[a-zA-Z0-9]+$", yy= #"^[a-zA-Z0-9]+$", zz= #"(.*?)\.(vpf)" }
);
Its working for .vpf

301 redirect for old Ajax permalinks

My clients old site was running through Wix.
Wix creates AJAX permalinks like this: old-domain.com/#!about/c20r9 instead of this: old-domain.com/about
I have developed a new WordPress site for them via new-domain.com. old-domain.com has been added to new-domain.com as a domain alias.
I would like to re-direct old page urls from old-domain.com to specific pages on new-domain.com. For example: old-domain.com/#!about/c20r9 should re-direct to: new-domain.com/about.
I understand that 301 redirect rules do not work as the server will not recognise hash urls.
How can I re-direct the old URLs for old-domain.com to new-domain.com?
As mentioned in my comment, JavaScript is the way to go as the fragment (#...) is never sent to the server.
In your specific case, you could use the following JS code to redirect your page accordingly.
Automatic mode: Use if the page names have not changed:
// Get the current hash
var currentHash = window.location.hash;
// If there is one, and it is in fact a hashbang, redirect it to the new URI.
// This extracts the 'about' from '#!about/c20r9', for example, and assigns the
// location (/about) once extracted.
if (currentHash.indexOf('#!') == 0){
window.location.assign(currentHash.replace(/^#!([^\/]+)\/.*/, '$1'));
}
Manual mode: Use if your page names differ (when comparing Wix to your migrated site). This method maps the redirects using an object, scans the object, and redirects if a match is found.
// Get the current hash
var currentHash = window.location.hash;
// If there is one, and it is in fact a hashbang, redirect it to the new URI,
// based on the array set out.
if (currentHash.indexOf('#!') == 0) {
// Get the old page name from the hash
var oldPageHash = currentHash.replace(/^#!([^\/]+)\/.*/, '$1');
// Define the redirects (old and new counterparts)
var redirects = {
'foo-page': 'new-foo-page',
'bar-page': 'new-bar-page',
}
// Loop through the redirects and set the location if there is a match
for (var oldPage in redirects) {
if (redirects.hasOwnProperty(oldPage)) {
if (oldPage == oldPageHash) {
window.location.assign(redirects[oldPage]);
}
}
}
}

Redirecting to relative path using Laravel 4

Is it possible, in Laravel 4.1, to redirect to a relative path instead of the full path ? If we look at the UrlGenerator::to method, here what we have:
public function to($path, $extra = array(), $secure = null)
{
if ($this->isValidUrl($path)) {
return $path;
}
$scheme = $this->getScheme($secure);
$tail = implode('/', array_map('rawurlencode', (array) $extra));
$root = $this->getRootUrl($scheme);
return $this->trimUrl($root, $path, $tail);
}
This will act like this (meta-code):
mysite.com/url Redirect::to('/test'); => mysite.com/test
What I'd want it's to be redirected to a relative URL:
mysite.com/url Redirect::to('/test'); => /test
The problem it's that the company I'm working for, use a ReverseProxy to redirect all the traffic to HTTPS protocol, and with this kind of laravel redirects I keep getting redirected from HTTP to HTTPS :
call: GET http:// mysite.com
proxy: GET https:// mysite.com
redirect to login: GET http:// mysite.com / login
proxy: GET https:// mysite.com / login
submit login: POST http:// mysite.com / login
proxy: POST https:// mysite.com / login
And the problem is that the submit form fail.
Is there a possibility to redirect to the relative path and let the proxy define the root url / protocol to use ?
I'm on Laravel 4.2, I'm using Redirect::away('/test'), not sure if the function is there yet on Laravel 4.1.

What's the easiest way to display content depending on the URL parameter value in DocPad

I'd like to check for an URL parameter and then display the confirmation message depending on it.
E.g. if I a GET request is made to /form?c=thankyou docpad shows the form with thank you message
I think there is two basic ways to do this.
look at the url on the server side (routing) and display differing content according to URL parameters
Look at the parameter on the client side using JavaScript and either inject or show a dom element (eg div) that acts as a message box.
To do this on the server side you would need to intercept incoming requests in the docpad.coffee file in the serverExtend event. Something like this:
events:
# Server Extend
# Used to add our own custom routes to the server before the docpad routes are added
serverExtend: (opts) ->
# Extract the server from the options
{server} = opts
docpad = #docpad
# As we are now running in an event,
# ensure we are using the latest copy of the docpad configuraiton
# and fetch our urls from it
latestConfig = docpad.getConfig()
oldUrls = latestConfig.templateData.site.oldUrls or []
newUrl = latestConfig.templateData.site.url
server.get "/form?c=thankyou", (req,res,next) ->
document = docpad.getCollection('documents').findOne({relativeOutPath: 'index.html'});
docpad.serveDocument({
document: document,
req: req,
res: res,
next: next,
statusCode: 200
});
Similar to an answer I gave at how to handle routes in Docpad
But I think what you are suggesting is more commonly done on the client side, so not really specific to Docpad (assumes jQuery).
if (location.search == "?c=thankyou") {
$('#message-sent').show();//show hidden div
setTimeout(function () {
$('#message-sent').fadeOut(1000);//fade it out after a period of time
}, 1000);
}
This is a similar answer I gave in the following Docpad : show error/success message on contact form
Edit
A third possibility I've just realised is setting the document to be dynamically generated on each request by setting the metadata property dynamic = true. This will also add the request object (req) to the template data passed to the page. See Docpad documentation on this http://docpad.org/docs/meta-data.
One gotcha that gets everyone with setting the page to dynamic is that you must have the docpad-plugin-cleanurls installed - or nothing will happen. Your metadata might look something like this:
---
layout: 'default'
title: 'My title'
dynamic: true
---
And perhaps on the page (html.eco):
<%if #req.url == '/?c=thankyou':%>
<h1>Got It!!!</h1>
<%end%>

iTunes Search API - HTTPS artworkUrl?

When I run a query against the iTunes Search API over SSL, most of the URL's returned are provided via HTTPS:
https://itunes.apple.com/search?term=rihanna
However, the artworkUrl results are served over HTTP and updating them manually throws an error since the SSL certificate doesn't match on the domain they're using.
Is there a way to grab these images over HTTPS instead of HTTP?
You have to replace the sub domain:
http://is<n> with https://is<n>-ssl
Example:
http://is5.mzstatic.com/image/thumb/Music117/v4/dd/48/4a/dd484afb-2313-0a1a-ccf1-ff28a02ae2ca/source/100x100bb.jpg
to
https://is5-ssl.mzstatic.com/image/thumb/Music117/v4/dd/48/4a/dd484afb-2313-0a1a-ccf1-ff28a02ae2ca/source/100x100bb.jpg
iTunes does not support the album art or song previews over HTTPS (yet).
The change over of the tools and links to HTTPS was recent (only four months ago):
http://www.apple.com/itunes/affiliates/resources/blog/secure-links-to-itunes---content-and-tools.html
New to SO and Swift - stumbled over this problem until finding this Q, and the answers above. The following worked for me:
func withHTTPS() -> URL? {
var components = URLComponents(url: self, resolvingAgainstBaseURL: true)
components?.scheme = "https"
let host = (components?.host)!
components?.host = host.replacingOccurrences(of: ".", with: "-ssl.", options: .caseInsensitive, range: host.range(of: "."))
return components?.url
}
called using:
guard let url = item.artworkURL.withHTTPS() else { return }